1

I want to make sure resources in web application (css, js, and images) will be refreshed every time I change them leaving the same name of the resource (so that I dont need to change references in html to it). So I guess there are at least two obvious solutions:

  1. Include ETAG in the response header
  2. Include Hash in Url (ie /css/{hash}/style.css)

I liked second idea better, because maybe some older proxies or browser would ignore etag - is that right ? But it is bit more difficult to put hashes into url of images in css. So finally I guess I will go with the first option for images, and both the first and the second for css and js.

What are your thougts ? Would first just be enough, and every fairly modern software will request refresh of the resource if it will change.

2 Answers 2

0

Concerning the second, you could use a Apache Rewrite Rule to accomplish that. I assume you could hash the date modified/created of the file with whatever programming language you are using.

.htaccess

RewriteEngine on RewriteBase / RewriteRule ^css/[^/]+/style.css$ css/style.css [L]

1
  • Apache ? htaccess ? this is asp.net and probably windows.
    – Aristos
    Jun 26, 2011 at 16:52
0

From my experience an etag is usually respected by browsers/proxies. However I've generally found that I've needed to set the last modified also. Also make sure that you have the etag formed correctly as some browsers are picky about that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.