Forum Moderators: open

Message Too Old, No Replies

timestamp in js file

         

FiRe

11:08 pm on Oct 27, 2006 (gmt 0)

10+ Year Member



Whats the point of this...

<script type="text/javascript" src="main.js?1161990407"></script>

...having the timestamp included in the js file name? I noticed it on sites such as facebook?!

penders

10:39 am on Oct 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think it tries to ensure that
main.js
is not pulled from the local browser cache, but instead is requested a fresh from the server each time (whenever the timestamp is changed). Perhaps
main.js
changes often?

FiRe

10:40 am on Oct 28, 2006 (gmt 0)

10+ Year Member



yeh thats what I thought! to prevent the cache is there code within the js file that ensures this, or does the browser interpret the timestamp and stops caching the js file?

penders

12:18 pm on Oct 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...to prevent the cache is there code within the js file that ensures this...

Not necessarily... unless there is perhaps some server-side script that returns a "

pragma: no-cache
" etc. header?!? But I don't think the idea is to prevent caching.

...or does the browser interpret the timestamp and stops caching the js file?

Like I say, I don't think they are trying to stop the file from being cached, just to pull the latest from the server when it needs to. "main.js?1161990407" will be cached. The '?1161990407' (query string) part is 'ignored' when simply referencing the file from the <script> tag, but is used by the browser to store a reference to the file when it is cached. Every time that timestamp is changed then the idea is the browser won't find a match in the cache so pull another copy from the server. I am assuming that the timestamp is not changing on every refresh?! Perhaps every few days/weeks or so? So the file should be cached in the meantime.