CSS browser caching

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
trixter

CSS browser caching

Post by trixter »

Is anyone working on a means by which CSS may be called seperately rather than included in every webpage? I ask this because it adds a lot of size to each file that is transfered, and in some cases can be more than 50% of each page hit. If the CSS is loaded seperately the first hit would be somewhat slower but after that subsequent hits would be much faster, and for busy sites the network usage lower.

Most modern browsers are set to cache information they receive, and issue a command to check the date of the content to see if its been modified since they last obtained a copy. Should the individual style sheets be done in this way it could result in a slightly lower network cost for each page served.

The information is already in the DB, this is just a different means of pulling it out.

on a cache hit (ie its already cached)
DB is accessed to check the timestamp of the CSS page - cpu cost
Network usage is lower since style sheet isnt transmitted
pages should render slightly faster, giving the user a better experience

on a cache miss
very little difference between what is currently done and current solution
slight CPU cost due to additional thread/process to serve the CSS page
very slight network overhead (GET request, TCP handshake) added

It has been my experience that CPU is cheaper than network, as such this may be a handy thing to do. Can anyone else see a problem wtih this?
trixter

CSS

Post by trixter »

sort of. That does not address the underlying issue (although wishy said that he wanted to do something simmilar to what I discussed).

I am aware that I can reference external stylesheets via the stylesheet tag in the HTML section. However, I wanted my stylesheets to be in the database, not extenral. For that, code must be written to see what stylesheet I want, fetch it, return error if its not present.

Since it appears, based on your previous post, that it is on the list of things to do, I will try to see what the status of that is, and where that can fit into my schedule for doing it (I have raised many issues regarding features tonight, I cant work on all of them at the same time :)
trixter

its already there!

Post by trixter »

looking at 0.7.3 (I just upgraded :/ ) its there.. by calling /stylesheet.php?templateid= it will display the stylesheet for that template. In this way it is in theory possible to cache.

The only thing I dont see is a modified check, so that it can truely be cached, but this part is already done, so maybe I will get bored and add in a check for last modified and set appropriate HTTP headers.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

CSS browser caching

Post by Ted »

I agree that this is a good change. Originally, it used stylesheet.php, but I brought the CSS to be inline because of the preview function. Just never got around to splitting it back out again. I'll put that on my TODO list for 0.8.
Post Reply

Return to “Developers Discussion”