• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Speed up your site.. lose {stylesheet}
PostPosted: Fri Mar 09, 2007 1:42 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Jan 26, 2006 11:46 am
Posts: 700
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:

http://www.yourdomain.com/stylesheet.php?templateid=23" />
http://www.yourdomain.com/stylesheet.php?templateid=23&mediatype=print" />

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.

/uploads/yoursite-screen.css" />
/uploads/yoursite-print.css" />

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').

_________________
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info


Last edited by kermit on Fri Mar 09, 2007 1:53 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Fri Mar 09, 2007 5:05 am 
My cache project includes a stylesheet tag which do the same :) ...


Top
  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Fri Mar 09, 2007 10:38 am 
Offline
Forum Members
Forum Members

Joined: Fri May 12, 2006 7:40 am
Posts: 221
In Wordpress you can also edit a static stylesheet in the back-end, maybe thats a good idea for cmsms also?


Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Fri Mar 09, 2007 10:56 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Feb 06, 2007 4:01 am
Posts: 63
Location: Dallas, TX
Signex wrote:
In Wordpress you can also edit a static stylesheet in the back-end, maybe thats a good idea for cmsms also?


I like this idea; the same editing capabilities could also support other "external" files like menu templates that aren't saved into the database. Some permission setting might be needed to allow this type of "live" file editing.


Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Sat Mar 10, 2007 1:02 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Jan 26, 2006 11:46 am
Posts: 700
cyberman wrote:
My cache project includes a stylesheet tag which do the same :) ...


{cstylesheet} puts the cached css in the output html, so you trade css generation time for larger html pages (which still must be transferred to the browser on every page view). allowing the browser to cache the stylesheets is more efficient and faster... perhaps {cstylesheet} could be updated to serve the actual text/css, allow browser caching, provide the 304's when they apply, and maybe have a configurable expires parameter so the site admin still has some control over how long the stylesheets are cached by the browser.


i have been messing around with {ccontent} though. i'm using the rss module on one site. a frontpage feed i want updated every 2-3 hours, but feeds on other pages i only want updated daily. IF {ccontent} caches the rss module output, then i can use it to control the rss updates on those other pages without hacking the rss module code to pass along a lifetime parameter of its own (rss module caches the feeds).


i've also played around with a different site, and put EVERYTHING above the content block on the page, up to and including in the template in a global content block, and then on the top line of every page's content area references that gcb... breadcrumbs? cached. meta data? cached. MENUS? cached......  and i end up with something like this...





yes, that's SIX queries and under 3.5mb ram....

(note this is a 'static' web site, so caching everything is no big deal.. i set the lifetime real high and will just clear the cache manually on content changes during this little experiment)


(note mysql server does not reside on 'localhost', so part of that 0.12 is latency across the lan..)


EDIT.. this little scheme has basically been obsoleted by my full-page caching mod:
http://forum.cmsmadesimple.org/index.ph ... 244.0.html

_________________
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info


Last edited by kermit on Sun Jun 29, 2008 10:42 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Sat Mar 10, 2007 7:26 pm 
Offline
Support Guru
Support Guru

Joined: Mon Jul 24, 2006 3:27 pm
Posts: 3694
Location: Paris
Has someone tried a somewhat benchmark (features and performance) with :
-this hack from kermit, (@kermit : I like to have CSS as real static files, but managed from CMSms)
-the ccache module from cyberman,
-the out of the box current CMSms v1.0.4 behind an apache mod_cache reverse caching proxy,
-the integrated "full page caching" of CMSms v2.0, already in SVN ?
I'm just curious and looking for 2.0. 304 smiles to everybody !
Pierre M.

_________________
-- Pierre, support team member. comodérateur du forum francophone.
Please read "how to submit installation/support requests" before posting. Don't send private messages to ask for support.
Want to contribute to CMSms ? Improve the wiki with your forum account.


Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Sun Apr 01, 2007 12:22 am 
So the full page caching is already in the svn?


Top
  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Mon Apr 02, 2007 2:36 pm 
Offline
Support Guru
Support Guru

Joined: Mon Jul 24, 2006 3:27 pm
Posts: 3694
Location: Paris
Yes, full page caching is already in the svn according to my understanding of this :
http://blog.cmsmadesimple.org/2007/02/0 ... your-help/

Pierre M.

_________________
-- Pierre, support team member. comodérateur du forum francophone.
Please read "how to submit installation/support requests" before posting. Don't send private messages to ask for support.
Want to contribute to CMSms ? Improve the wiki with your forum account.


Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Tue Apr 17, 2007 8:18 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1082
Location: The Netherlands
When using
Code:
{ccontent lifetime='3600'}
in the template, the Guestbook module gives an error:
Quote:
string(127) "Smarty error: [in content:content_en line 1]: syntax error: invalid attribute name: '


The url is: http://www.uisge-beatha.eu/index.php?page=gastenboek

Anyone else who encountered this problem?

Thanks,
G


Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Tue Apr 17, 2007 8:22 am 
Maybe there's a bug so I have to rewrite ccontent now (write it to my todo list) ...


Top
  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Tue Apr 17, 2007 8:23 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1082
Location: The Netherlands
oopps, hd to clear the cache first. Error is gone after doing so  ;)


Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Wed Apr 18, 2007 12:25 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1082
Location: The Netherlands
By using cstylesheet and ccontent, I noticed that Album is having troubles. Only the album thumbnails are shown, however clicking a thumbnail does not show the pictures laying under that specific thumbnail. I've cleare the cache oevr and over, but that did not solve the problem. Anyone else who recognize this issue?


Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Wed Apr 18, 2007 2:37 pm 
This is my solution:

I created a new directory in the CMSMS base directory and named it "stylesheet".
I copied the stylesheets from the administration area into some files.
They start with the media and end with ".css".
These are the contents:
Code:
handheld.css
print.css
screen.accessibility-and-cross-browser-tools.css
screen.module.news.css
screen.navigation.simple-vertical.css
screen.standard.css


Then I created a user tag called "static_stylesheet":

Code:
$dir = dir('stylesheet');

while ($file = $dir->read()) {
    if ($file{0} == '.') continue;
    if (!preg_match('/\.css$/i', $file)) continue;

    $media = preg_replace('/^([^\.]+)\..*$/', '\1', $file);
    echo "<link rel='stylesheet' type='text/css' media='$media' href='stylesheet/$file' />\n";
}


Then I replaced {stylesheet} by {static_stylesheet}.

And it works :)

Henrik


Top
  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Thu Apr 19, 2007 5:33 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1082
Location: The Netherlands
Thanks Henrik,

This takes some more time for me to realise. Have a look at it later.

Gregor


Top
 Profile  
 
 Post subject: Re: Speed up your site.. lose {stylesheet}
PostPosted: Fri Apr 20, 2007 1:58 am 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 217
Location: Nashville, USA
henrik wrote:
This is my solution:
...
{static_stylesheet}.


This is good. You could even take this a step further and use gzip compression on each of the css files inside your stylesheet directory.

First rename your stylesheets with a .php instead of .css
Then add this php code to the top of the sheet

Code:
<?php
ob_start ("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>


Here's an article that talks about this:
http://www.fiftyfoureleven.com/weblog/w ... zip-method

_________________
--
LinkedIn.com
--
Internal Page 301 Redirect
--
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner