• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS made Simple Czech Site Zur deutschsprachigen Supportseite Site francophone Sitio en Castellano CMSMS - Magyarország CMSMS -  ???????
Pages: [1] 2 3
  Print  
Author Topic: Speed up your site.. lose {stylesheet}  (Read 20466 times)
0 Members and 1 Guest are viewing this topic.
kermit
Power Poster
***

Karma: 38
Offline Offline

Posts: 741


Hug a Penguin today!


« on: 08 Mar 2007, 20:42 »

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:

<link rel="stylesheet" type="text/css" href="http://www.yourdomain.com/stylesheet.php?templateid=23" />
<link rel="stylesheet" type="text/css" media="print" href="http://www.yourdomain.com/stylesheet.php?templateid=23&amp;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.

<link rel="stylesheet" type="text/css" href="/uploads/yoursite-screen.css" />
<link rel="stylesheet" type="text/css" media="print" href="/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) Wink

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. Wink ...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').
« Last Edit: 08 Mar 2007, 20:53 by kermit » Logged

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
cyberman
Support Team
Power Poster
***

Karma: 150
Offline Offline

Posts: 8943


Reality.sys is corrupt. Reboot universe (Y/N)?


WWW
« Reply #1 on: 09 Mar 2007, 00:05 »

My cache project includes a stylesheet tag which do the same Smiley ...
Logged

"2 hours of try and error can save 10 minutes of manual reading"
(2 Stunden Ausprobieren können Ihnen 10 Minuten Handbuchlesen ersparen)
------------------------------------------------------------------------------------
Für deutschsprachige Anwender / for german speaking users only
http://www.cmsmadesimple.de/ - deutschsprachige Support-Seite für CMS made simple
http://demo.cmsmadesimple.de/ - Informationen der CMSms-Musterinstallation in deutsch
http://wiki.cmsmadesimple.org/index.php/Main_Page/de - deutschsprachiges Wiki für CMS made simple
http://dev.cmsmadesimple.org/projects/german/ - deutsche Sprachdateien für CMS made simple
-----
http://themes.cmsmadesimple.org/Full_Themes.html - Templates für CMS made simple (engl.)
http://www.cmsmadesimple.org/apidoc/ - API für CMSms 1.x (engl.)
Signex
Forum Members
**

Karma: 4
Offline Offline

Posts: 222


« Reply #2 on: 09 Mar 2007, 05:38 »

In Wordpress you can also edit a static stylesheet in the back-end, maybe thats a good idea for cmsms also?
Logged

have you visited the cmsms blog lately?
chead
Forum Members
**

Karma: 5
Offline Offline

Posts: 64



« Reply #3 on: 09 Mar 2007, 17:56 »

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.
Logged
kermit
Power Poster
***

Karma: 38
Offline Offline

Posts: 741


Hug a Penguin today!


« Reply #4 on: 09 Mar 2007, 20:02 »

My cache project includes a stylesheet tag which do the same Smiley ...

{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 <head> 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...

<!-- Generated in 0.126577 seconds by CMS Made Simple using 6 SQL queries and 3552288 bytes of memory  -->

<!-- Generated in 0.129864 seconds by CMS Made Simple using 6 SQL queries and 3551736 bytes of memory  -->

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.php/topic,23244.0.html
« Last Edit: 29 Jun 2008, 18:42 by kermit » Logged

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
Pierre M.
Support Team member
Support Guru
Power Poster
****

Karma: 32
Offline Offline

Posts: 3736

Please keep it simple


« Reply #5 on: 10 Mar 2007, 14:26 »

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.
Logged

-- 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.
biffs
Forum Members
**

Karma: 1
Offline Offline

Posts: 39


« Reply #6 on: 31 Mar 2007, 20:22 »

So the full page caching is already in the svn?
Logged
Pierre M.
Support Team member
Support Guru
Power Poster
****

Karma: 32
Offline Offline

Posts: 3736

Please keep it simple


« Reply #7 on: 02 Apr 2007, 10:36 »

Yes, full page caching is already in the svn according to my understanding of this :
http://blog.cmsmadesimple.org/2007/02/08/20-needs-your-help/

Pierre M.
Logged

-- 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.
Gregor
Power Poster
***

Karma: 2
Offline Offline

Posts: 752



WWW
« Reply #8 on: 17 Apr 2007, 04:18 »

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
Logged
cyberman
Support Team
Power Poster
***

Karma: 150
Offline Offline

Posts: 8943


Reality.sys is corrupt. Reboot universe (Y/N)?


WWW
« Reply #9 on: 17 Apr 2007, 04:22 »

Maybe there's a bug so I have to rewrite ccontent now (write it to my todo list) ...
Logged

"2 hours of try and error can save 10 minutes of manual reading"
(2 Stunden Ausprobieren können Ihnen 10 Minuten Handbuchlesen ersparen)
------------------------------------------------------------------------------------
Für deutschsprachige Anwender / for german speaking users only
http://www.cmsmadesimple.de/ - deutschsprachige Support-Seite für CMS made simple
http://demo.cmsmadesimple.de/ - Informationen der CMSms-Musterinstallation in deutsch
http://wiki.cmsmadesimple.org/index.php/Main_Page/de - deutschsprachiges Wiki für CMS made simple
http://dev.cmsmadesimple.org/projects/german/ - deutsche Sprachdateien für CMS made simple
-----
http://themes.cmsmadesimple.org/Full_Themes.html - Templates für CMS made simple (engl.)
http://www.cmsmadesimple.org/apidoc/ - API für CMSms 1.x (engl.)
Gregor
Power Poster
***

Karma: 2
Offline Offline

Posts: 752



WWW
« Reply #10 on: 17 Apr 2007, 04:23 »

oopps, hd to clear the cache first. Error is gone after doing so  Wink
Logged
Gregor
Power Poster
***

Karma: 2
Offline Offline

Posts: 752



WWW
« Reply #11 on: 18 Apr 2007, 08:25 »

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?
Logged
henrik
Guest
« Reply #12 on: 18 Apr 2007, 10:37 »

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 Smiley

Henrik
Logged
Gregor
Power Poster
***

Karma: 2
Offline Offline

Posts: 752



WWW
« Reply #13 on: 19 Apr 2007, 01:33 »

Thanks Henrik,

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

Gregor
Logged
mww
Beta Tester
Forum Members
*

Karma: 3
Offline Offline

Posts: 191



WWW
« Reply #14 on: 19 Apr 2007, 21:58 »

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/web-development/css/the-definitive-css-gzip-method


Logged

----------------------------------------------------------------------------
Building quality websites using the best CMS available, CMS Made Simple!
I'm always using the latest CMSMS version available.

John D. Beatrice
http://www.linkedin.com/in/johnbeatrice

"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo
Pages: [1] 2 3
  Print  
 
Jump to: