It appears to be a away of time stamping the css file. The query string would be a way of telling the browser "if you request this file again and that query string version is not available, you'll need to take a new version".
I've never seen this done, and I'm not clear why someone would do it. CSS files usually don't change very frequently, and when they do change, then normal server requests should handle it effectively.
So I am also abut curious - even a bit mystified. Anyone have any deeper insight than I do"
hmnn... thanks for your insight Ted.
I feel this has something to do with the browser caching.
Normally people set long times into the future using php headers or equivalent. In that case the page wont look for a fresh file if the name is same.
To override that probably these people use a query string approach.
But some expert advice would be welcome. heeeeelllp
|CSS files usually don't change very frequently, and when they do change, then normal server requests should handle it effectively. |
That's not always the case. I've seen plenty of times when a new CSS file is available, but the browser continues to serve up a cached one.
The above example is how you could implement a "cache killer". In other words, when you update the CSS file, you also update the HTML and change the value after the ?. This will force the browser to request the file again and see that it has changed. Often times the value is a timestamp, but it really could be any value as long as it can be changed to be a new unique value. For example, you could do:
It really doesn't matter what the value is.
kool...so my guess was right. Thanks for conforming Fotiman.
So as per you we could also have css files like css_15_10_2010.css and that should have the same effect. Just that I dont have to rename my file physically only a html update will do.
I am clear about it now.
The thing that still puzzles me is the length of that decimal in the query string. It looks like they intend to have MANY revisions of the CSS file.
What would be revealing is to dig into a specific case and immediately ping the server for just the CSS file that was served a moment before.
They are probably using a timestamp (in milliseconds) to guarantee uniqueness, hence the length. I don't think it was to suggest MANY revisions of the file.
And why would you want to have a unique stamp for a css file - that's what I can't figure out. Wouldn't you WANT to use the browser cache most of the time?
Yes... as I said above, this value only gets changed when you make changes to the file and want to force the browser to pick up the new version. So developer creates version one of the file on, say, October 1st and the HTML has a markup like this:
<link href="style.css?ck=0.656089390631731" ...
The browser will recognize that it hasn't fetched this file with this query string, and force the new download (where it may cache it again, so future requests using this same querystring use the cached version).
That remains unchanged until the developer makes a change to the CSS file on, say, October 14th. He/she wants to make sure browsers don't continue to use a cached version of the file, so the developer changes the link in the HTML to something different:
<link href="style.css?ck=0.656089512885179" ...
Right, this is a workaround to avoid browser caching if the tools are out of your control and applies to *any* static file. The exceptions are of course dynamic scripts that may do something with the query string, like php, etc.