Click here to get back home

Can I force the client to stop caching old stylesheets and javascript?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Can I force the client to stop caching old stylesheets and javascript? mark4asp 10-16-2007
Posted by mark4asp on October 16, 2007, 9:50 am
Please log in for more thread options
Can I force the client to stop caching old stylesheets and javascript?

In my dynamic web-site, I need to force the client to stop caching old
versions of my stylesheets and javascript. Can I do this by including
a querystring with the url with each external stylesheet and script
file declaration?

For example:

<link type="text/css" rel="stylesheet" href="../images/menu.css?
v=1" />
<script type="text/javascript" src="../javascript/menu.js?v=1"></
script>

This is far easier, for me, than coding the web-server to change the
file headers. I just want confirmation that this will work. It seems
obvious that it should but I'm curious as to why I've never come
across this technique before.


Posted by Rik Wasmus on October 16, 2007, 10:53 am
Please log in for more thread options


> Can I force the client to stop caching old stylesheets and javascript?=

>
> In my dynamic web-site, I need to force the client to stop caching old=

> versions of my stylesheets and javascript. Can I do this by including
> a querystring with the url with each external stylesheet and script
> file declaration?
>
> For example:
>
> <link type=3D"text/css" rel=3D"stylesheet" href=3D"../images/menu.c=
ss?
> v=3D1" />
> <script type=3D"text/javascript" src=3D"../javascript/menu.js?v=3D1=
"></
> script>
>
> This is far easier, for me, than coding the web-server to change the
> file headers.

Shouldn't be...

> I just want confirmation that this will work. It seems
> obvious that it should but I'm curious as to why I've never come
> across this technique before.

It works (well, as long as you keep changing the query string), and is =

widely in use.
-- =

Rik Wasmus

Posted by André Gillibert on October 24, 2007, 5:42 pm
Please log in for more thread options
mark4asp wrote:

> Can I force the client to stop caching old stylesheets and javascript?
>
> In my dynamic web-site, I need to force the client to stop caching old
> versions of my stylesheets and javascript. Can I do this by including
> a querystring with the url with each external stylesheet and script
> file declaration?

Yes, but that's evil. Fortunately, you may be punished by a low google
rank! Crawlers assume that a URI uniquely identifies a resource.

Use the HTTP headers (e.g. set expiration to zero second). If the page is
generated by a script or contains SSI, your server should use the correct
headers by default.
If the page is static, then, why preventing caching? To improve the page
hits statistics? That would be stupid and evil.
What is it for?


> I just want confirmation that this will work.

It will work as using pseudonyms to commit evil deeds reduces the chance
of being identified.

> It seems obvious that it should but I'm curious as to why I've never come
> across this technique before.
>
Because, modifying HTTP headers is much nicer, much more civilized, and
much more natural. It's the direct, obvious, fine, standardized way to
control caching. Your way, is worse than failure:
http://worsethanfailure.com/Default.aspx


--
If you've a question that doesn't belong to Usenet, contact me at

Similar ThreadsPosted
Post data to server from javascript on client side January 17, 2005, 3:47 pm
Prevent caching by ISP October 8, 2004, 9:45 pm
Caching graphics April 11, 2006, 5:43 pm
Understanding caching February 19, 2008, 11:31 pm
alternate stylesheets August 12, 2004, 1:37 pm
Page Caching Problem January 9, 2006, 8:01 am
User stylesheets for specific sites December 21, 2005, 8:33 am
Including CSS Stylesheets - or @import? January 17, 2007, 9:25 am
Instant startup of embedded quicktime content, is it possible? Caching is no help. February 20, 2007, 2:53 pm
Dealing with overriding styles with stylesheets in Microsoft Word November 19, 2004, 7:28 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap