![]() |
CSS Timestamps
I have seen css files that have timestamp parameters, or so it seems to be a timestamp, since it's the same length, and such.
e.g. example.com/foo.css?102193243 |
CSS/JS Timestamps example
I've written about this here: http://www.electrictoolbox.com/javas...le-timestamps/
You need to be wary of doing what I suggest if your site is busy though because there's overhead in checking timestamps of multiple files for each page request. In those instances it might be better to just do e.g. foo.css?some-unique-value |
Could this not be achieved with .htaccess? Something like the following in the CSS directory:
Code:
<Files *> |
But then the browser would never cache it, and have to download the CSS/JS file on every page request. Not really ideal. The idea with the ?value at the end of the filename is that you can control when the browser *must* download it and it will then continue to cache that version of the file.
|
Quote:
|
Coincidence!
How about the Apache module mod_expires? I've used it once or twice, but never for caching. However, you can set any HTTP header with an expiration time, so it should be just fine. |
That will set the time limit for caching, but you still can't force the browser to request a new version when you change the contents of the stylesheet. This doesn't matter so much for trivial changes, but if you make major changes you're still going to want to either rename the file or use ?something to effectively rename the file. That way on the the next page request the browser gets the updated version and everything renders correctly. Otherwise there may be layout issues until the cached copy expires.
|
I personally version my css files so I would start with style001.css and so on.
This way I can set the maximum expires time and if I need to make any changes I can upload the new file as style002.css. |
That's what I used to do but I found it a bit of a hassle having multiple versions of files with different names, especially if you're doing a lot of CSS updates. I now version them after the date and time like e.g. style.css?20081218.1424
|
| All times are GMT. The time now is 11:39 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0