<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: CSS Caching Hack</title>
	<atom:link href="http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/</link>
	<description>Graphic Artist, Technophile, Web Librarian, Embarrassingly cute spelling mistakes.</description>
	<lastBuildDate>Tue, 02 Mar 2010 20:56:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andrew Philpott</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49842</link>
		<dc:creator>Andrew Philpott</dc:creator>
		<pubDate>Mon, 22 Feb 2010 16:12:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49842</guid>
		<description>Nice tip. Thanks!</description>
		<content:encoded><![CDATA[<p>Nice tip. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49836</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Mon, 25 Jan 2010 20:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49836</guid>
		<description>Just publish this as an explanation.

http://chad.ill.ac/post/353013824/an-effective-javascript-css-cache-busting-technique</description>
		<content:encoded><![CDATA[<p>Just publish this as an explanation.</p>
<p><a href="http://chad.ill.ac/post/353013824/an-effective-javascript-css-cache-busting-technique" rel="nofollow">http://chad.ill.ac/post/353013824/an-effective-javascript-css-cache-busting-technique</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49835</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Mon, 25 Jan 2010 19:40:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49835</guid>
		<description>We found when using this that IE holds client side caches much longer than desired.  Changing GET vars in the URL string will not always bust client side caches.  Our fix was to use PHP and rewrite rules to have the caches bust themselves based on the files mtime in the file system.  The mtime rather than being appended as a GET var is passed a directory (css/13456134/file.css) which forces IE to think it&#039;s a completely new file and bust the client side cache.

We&#039;ve written a PHP function to handle this automatically and put a rewrite rule in place to handle the resulting changes.

More info can be found here. 

http://chad.ill.ac</description>
		<content:encoded><![CDATA[<p>We found when using this that IE holds client side caches much longer than desired.  Changing GET vars in the URL string will not always bust client side caches.  Our fix was to use PHP and rewrite rules to have the caches bust themselves based on the files mtime in the file system.  The mtime rather than being appended as a GET var is passed a directory (css/13456134/file.css) which forces IE to think it&#8217;s a completely new file and bust the client side cache.</p>
<p>We&#8217;ve written a PHP function to handle this automatically and put a rewrite rule in place to handle the resulting changes.</p>
<p>More info can be found here. </p>
<p><a href="http://chad.ill.ac" rel="nofollow">http://chad.ill.ac</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iain Collins</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49825</link>
		<dc:creator>Iain Collins</dc:creator>
		<pubDate>Mon, 14 Dec 2009 18:04:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49825</guid>
		<description>This is absolutely the right way to handle this cross browser (I agree with others nothing this approach is not new, but apparently a lot of people missed the memo...).

A point to add is that it actually *increases* caching, in a desirable way.

By default, some browsers will aggressively cache a CSS file and refuse to update it even when the content changes, unless you perform a hack like this, while others will download and display the updated one (even if you didn&#039;t refresh and are just hitting the site again).

With additional GET parameters on the URL browsers that do not otherwise cache CSS files start to do so aggressively, until the GET parameters change. This side effect is desirable as it reduces the amount of superfluous traffic.

However, I suggest NOT simply appending the current timestamp (as suggested by one commentator) as that will increase the amount of traffic by having all browsers to re-download all CSS files on every page hit.

A $version variable is a more sensible approach (and on your development environment you can make it seconds since UNIX epoch if you want).</description>
		<content:encoded><![CDATA[<p>This is absolutely the right way to handle this cross browser (I agree with others nothing this approach is not new, but apparently a lot of people missed the memo&#8230;).</p>
<p>A point to add is that it actually *increases* caching, in a desirable way.</p>
<p>By default, some browsers will aggressively cache a CSS file and refuse to update it even when the content changes, unless you perform a hack like this, while others will download and display the updated one (even if you didn&#8217;t refresh and are just hitting the site again).</p>
<p>With additional GET parameters on the URL browsers that do not otherwise cache CSS files start to do so aggressively, until the GET parameters change. This side effect is desirable as it reduces the amount of superfluous traffic.</p>
<p>However, I suggest NOT simply appending the current timestamp (as suggested by one commentator) as that will increase the amount of traffic by having all browsers to re-download all CSS files on every page hit.</p>
<p>A $version variable is a more sensible approach (and on your development environment you can make it seconds since UNIX epoch if you want).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: experiencedDeveloper</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49823</link>
		<dc:creator>experiencedDeveloper</dc:creator>
		<pubDate>Tue, 08 Dec 2009 12:40:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49823</guid>
		<description>Jesus, I see there are lots of kids here developing hello world apps. Why not rename the file? Stupid question. Imagine doing that in a portal with dozens of webapps and hundreds of stylesheets under version control. Thanks to Stefan, his hack is the only practicable solution by now</description>
		<content:encoded><![CDATA[<p>Jesus, I see there are lots of kids here developing hello world apps. Why not rename the file? Stupid question. Imagine doing that in a portal with dozens of webapps and hundreds of stylesheets under version control. Thanks to Stefan, his hack is the only practicable solution by now</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Unbelieveable Stuff</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49806</link>
		<dc:creator>Unbelieveable Stuff</dc:creator>
		<pubDate>Wed, 11 Nov 2009 14:14:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49806</guid>
		<description>Nice One.......</description>
		<content:encoded><![CDATA[<p>Nice One&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mkukik</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49803</link>
		<dc:creator>mkukik</dc:creator>
		<pubDate>Tue, 03 Nov 2009 16:51:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49803</guid>
		<description>To summarize...
1. adding GET paramters does the job but browser tends to recache the file with dynamic parameters (especially IE) doesn&#039;t matter if parameter changes or not...

2. Renaming file is too much hassle... especially with versioning in place

3. With Apache and .httpaccess you can add rule to reference file style.css even if you call style134.css from HTML

  simply it will ignore number in the filename.
Example (depends on your setup):
  RewriteRule style[0-9]*\.css style.css

  of course you have to have some admin rights and be able to modify .htaccess...
I am sure this is possible in IIS as well

- Automatically changing filename number by filedatetime is not ideal either... coz it adds additional hit to the file on harddisk on every request, but it is comfortable and maybe worth the loss. Changing html each time css changes by hand is too risky.

4. HTTP cache headers... probably the most prefered way, but involves a bit of work to get it working...

At the end this work should be done by webserver(s) and should be done properly... which is not...

Use Fiddler to see effect of different scenarios :)</description>
		<content:encoded><![CDATA[<p>To summarize&#8230;<br />
1. adding GET paramters does the job but browser tends to recache the file with dynamic parameters (especially IE) doesn&#8217;t matter if parameter changes or not&#8230;</p>
<p>2. Renaming file is too much hassle&#8230; especially with versioning in place</p>
<p>3. With Apache and .httpaccess you can add rule to reference file style.css even if you call style134.css from HTML</p>
<p>  simply it will ignore number in the filename.<br />
Example (depends on your setup):<br />
  RewriteRule style[0-9]*\.css style.css</p>
<p>  of course you have to have some admin rights and be able to modify .htaccess&#8230;<br />
I am sure this is possible in IIS as well</p>
<p>- Automatically changing filename number by filedatetime is not ideal either&#8230; coz it adds additional hit to the file on harddisk on every request, but it is comfortable and maybe worth the loss. Changing html each time css changes by hand is too risky.</p>
<p>4. HTTP cache headers&#8230; probably the most prefered way, but involves a bit of work to get it working&#8230;</p>
<p>At the end this work should be done by webserver(s) and should be done properly&#8230; which is not&#8230;</p>
<p>Use Fiddler to see effect of different scenarios :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DailyJava</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49799</link>
		<dc:creator>DailyJava</dc:creator>
		<pubDate>Fri, 30 Oct 2009 06:51:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49799</guid>
		<description>VIOLA !!!

We recently gone through the same problem &amp; end up in renaming all css files. 

After reading this article I think we should have one tag (sorry I am from java backgroud so giving solution in J2EE words)which renders  tag having some postfix (may be release no.) to css and js files.

While doing build &amp; release we can define release no. &amp; rename all css and js files. This will not change css &amp; js files on your source repository. :) 

I am going to implement this in our project.</description>
		<content:encoded><![CDATA[<p>VIOLA !!!</p>
<p>We recently gone through the same problem &amp; end up in renaming all css files. </p>
<p>After reading this article I think we should have one tag (sorry I am from java backgroud so giving solution in J2EE words)which renders  tag having some postfix (may be release no.) to css and js files.</p>
<p>While doing build &amp; release we can define release no. &amp; rename all css and js files. This will not change css &amp; js files on your source repository. :) </p>
<p>I am going to implement this in our project.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dj</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49762</link>
		<dc:creator>dj</dc:creator>
		<pubDate>Thu, 24 Sep 2009 13:44:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49762</guid>
		<description>If you have access to PHP then use

style.css?&lt;=filemtime(&#039;style.css&#039;)&gt;

If the above doesn&#039;t come out properly then I said use:

filemtime(&#039;style.css&#039;)

to get the modified time of the file, so when you update and re-upload it, it will have a different number on the end and will therefore force browsers to re-cache it.

No need for name changing or editing the html each time you want to make a change in the stylesheet/javascript includes</description>
		<content:encoded><![CDATA[<p>If you have access to PHP then use</p>
<p>style.css?&lt;=filemtime(&#8217;style.css&#8217;)&gt;</p>
<p>If the above doesn&#8217;t come out properly then I said use:</p>
<p>filemtime(&#8217;style.css&#8217;)</p>
<p>to get the modified time of the file, so when you update and re-upload it, it will have a different number on the end and will therefore force browsers to re-cache it.</p>
<p>No need for name changing or editing the html each time you want to make a change in the stylesheet/javascript includes</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Hayden</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49750</link>
		<dc:creator>Stefan Hayden</dc:creator>
		<pubDate>Thu, 10 Sep 2009 11:13:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49750</guid>
		<description>@zero Well if you rename the file then you have the change the file name AND what it&#039;s called in the HTML. So more work.

Nut you could rename the file if you wanted to. If your website is setup well there should only be 1 reference to the css file in some header.php file. Chamging the v= is just a very low effort way to get the no caching effect.</description>
		<content:encoded><![CDATA[<p>@zero Well if you rename the file then you have the change the file name AND what it&#8217;s called in the HTML. So more work.</p>
<p>Nut you could rename the file if you wanted to. If your website is setup well there should only be 1 reference to the css file in some header.php file. Chamging the v= is just a very low effort way to get the no caching effect.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zero</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49749</link>
		<dc:creator>zero</dc:creator>
		<pubDate>Thu, 10 Sep 2009 03:58:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49749</guid>
		<description>Thanks for the tip. works well.

but one question: if you have to change the &quot;style.css?version=X&quot; value for all references, why not just rename the file as style.versionX.css?</description>
		<content:encoded><![CDATA[<p>Thanks for the tip. works well.</p>
<p>but one question: if you have to change the &#8220;style.css?version=X&#8221; value for all references, why not just rename the file as style.versionX.css?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kobe</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49747</link>
		<dc:creator>Kobe</dc:creator>
		<pubDate>Tue, 08 Sep 2009 11:30:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49747</guid>
		<description>xhref isnt valide. why not:

href=&quot;style.css?version=xy&quot; ???</description>
		<content:encoded><![CDATA[<p>xhref isnt valide. why not:</p>
<p>href=&#8221;style.css?version=xy&#8221; ???</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jasmin Halkic</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49745</link>
		<dc:creator>Jasmin Halkic</dc:creator>
		<pubDate>Tue, 08 Sep 2009 08:37:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49745</guid>
		<description>Very nice, thanks.</description>
		<content:encoded><![CDATA[<p>Very nice, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yes Web Can :: Programmazione :: Forzare l&#8217;aggiornamento della cache in automatico</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49741</link>
		<dc:creator>Yes Web Can :: Programmazione :: Forzare l&#8217;aggiornamento della cache in automatico</dc:creator>
		<pubDate>Wed, 02 Sep 2009 15:24:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49741</guid>
		<description>[...] costretto a cercare un alternativa. Grazie a Google ho scoperto che Stephen Hayden ha proposto un trucchetto per ovviare il problema. Il trucco consiste  nell&#8217;aggiungere una variabile GET alla fine del [...]</description>
		<content:encoded><![CDATA[<p>[...] costretto a cercare un alternativa. Grazie a Google ho scoperto che Stephen Hayden ha proposto un trucchetto per ovviare il problema. Il trucco consiste  nell&#8217;aggiungere una variabile GET alla fine del [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Laughlin</title>
		<link>http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/comment-page-2/#comment-49736</link>
		<dc:creator>Tim Laughlin</dc:creator>
		<pubDate>Fri, 07 Aug 2009 12:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/#comment-49736</guid>
		<description>Thanks, have done similar for other types of content.  Never occurred to me to use it on CSS.  You just saved me on a production release with some bad CSS behaviors.  Simply and straight forward.</description>
		<content:encoded><![CDATA[<p>Thanks, have done similar for other types of content.  Never occurred to me to use it on CSS.  You just saved me on a production release with some bad CSS behaviors.  Simply and straight forward.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
