Speed up your site.. lose {stylesheet}
Posted: Fri Mar 09, 2007 1:42 am
was messing around with some default installs and came to realize that stylesheet generation is a HUGE part of page load times.. so, give your cmsms site a speed boost by simply replacing {stylesheet} with static files... no database hits for the stylesheets and no php script to call for them translates to faster pages, especially on subsequent page loads where everything is already cached by the browser except the html page itself... TWICE AS FAST (here, anyway, and i just have one screen and one print stylesheet attached to a template)...
even when apache returns a 304 not modified for a stylesheet, cmsms still has to generate the css to see if it's different than what the browser says it has, the only thing different is that instead of sending the css, it sends the 304.
how to you find your compiled css code? load up a front-end page in your browser and look at the generated html source. you'll see lines like:
take the part in bold and load the links in your browser (take out the red part if it's there...). save the resulting output to text files like 'yoursite-screen.css' and 'yoursite-print.css'; upload them to your web space, and then replace the {stylesheet} tag in your template with links to those files.
So, when you've got your css tweaked to perfection, export it to static files and link to them instead.. you WILL see an improvement in site performance.. GUARANTEED (or your money back)
NOTE: if you've got more than one template, and they use different CSS.. find the styles common to all templates (those would be the stylesheet associations that are the same among them) and put them in one css file.. then find the ones needed for a specific template that can't go in that common file and stick those in a different one (and link to it only on the template that needs it). a lot of people with multiple templates and stylesheets can still probably get away with a single stylesheet if they do it right..
ANOTHER BONUS to losing {stylesheet} and linking to static files instead is you'll no longer have references to "stylesheet.php" clogging up things like webalizer and awstats....
and while you're at it, if you've only got a single template to your site, and no one will be messing around with the global meta data, stick your meta data (grab it from your page's output html so you don't miss anything) in there too and lose {metadata}.. another query chopped off each page.
ted, this part's for you.
...since css is static content, i dunno why it's generated on every page view.. it could generated and stored as static files (in addition to the database storage of each individual stylesheet.. cuz it is kinda cool having everything in the db for backup & server migrations) by the back-end whenever someone performs a task that would alter a template's generated css.... and then on the front-end, {stylesheet} could send the browser that static file, if it exists (or a 304 immediately), instead of generating it for every single page view (and if it does generate the css, it stores the static files for 'next time').
even when apache returns a 304 not modified for a stylesheet, cmsms still has to generate the css to see if it's different than what the browser says it has, the only thing different is that instead of sending the css, it sends the 304.
how to you find your compiled css code? load up a front-end page in your browser and look at the generated html source. you'll see lines like:
take the part in bold and load the links in your browser (take out the red part if it's there...). save the resulting output to text files like 'yoursite-screen.css' and 'yoursite-print.css'; upload them to your web space, and then replace the {stylesheet} tag in your template with links to those files.
So, when you've got your css tweaked to perfection, export it to static files and link to them instead.. you WILL see an improvement in site performance.. GUARANTEED (or your money back)

NOTE: if you've got more than one template, and they use different CSS.. find the styles common to all templates (those would be the stylesheet associations that are the same among them) and put them in one css file.. then find the ones needed for a specific template that can't go in that common file and stick those in a different one (and link to it only on the template that needs it). a lot of people with multiple templates and stylesheets can still probably get away with a single stylesheet if they do it right..
ANOTHER BONUS to losing {stylesheet} and linking to static files instead is you'll no longer have references to "stylesheet.php" clogging up things like webalizer and awstats....
and while you're at it, if you've only got a single template to your site, and no one will be messing around with the global meta data, stick your meta data (grab it from your page's output html so you don't miss anything) in there too and lose {metadata}.. another query chopped off each page.
ted, this part's for you.
