homepage Welcome to WebmasterWorld Guest from 50.16.130.188
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
How does this help file?cache=0.23423432
Need some help with this kind of file sources on html pages
NewDelhiSEO




msg:4216436
 8:25 pm on Oct 13, 2010 (gmt 0)

Hi friends...

Sometimes I see files in the html sourcecode like this..
style.css?cache=0.656089390631731

I want to hear from you what does this achieve?
Does this have to do anything with leveraging browser caching?
Any help is appretiated.

 

tedster




msg:4216442
 8:48 pm on Oct 13, 2010 (gmt 0)

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"

NewDelhiSEO




msg:4216449
 8:54 pm on Oct 13, 2010 (gmt 0)

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

Fotiman




msg:4216455
 8:57 pm on Oct 13, 2010 (gmt 0)

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:

style.css?ck=1
style.css?ck=2
style.css?ck=a

It really doesn't matter what the value is.

NewDelhiSEO




msg:4216461
 9:26 pm on Oct 13, 2010 (gmt 0)

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.

Very good.
I am clear about it now.

tedster




msg:4216468
 9:45 pm on Oct 13, 2010 (gmt 0)

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.

Fotiman




msg:4216637
 11:33 am on Oct 14, 2010 (gmt 0)

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.

tedster




msg:4216649
 11:55 am on Oct 14, 2010 (gmt 0)

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?

Fotiman




msg:4216668
 1:07 pm on Oct 14, 2010 (gmt 0)

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

rocknbil




msg:4216763
 4:21 pm on Oct 14, 2010 (gmt 0)

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.

image.jpg?2343543543

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved