If you include the hash in your URL, i.e.
http://server.example.com/styles/css.css?hash
it will reload when the hash changes because the browser will select it from the new URL:
Version 1:
<style type="text/css" link="styles/css.css?hash=v1" />
Version 2:
<style type="text/css" link="styles/css.css?hash=v2" />
Client caching is a client issue, let them do as they see fit: a new URL means that the resource has been changed, so it needs to be reloaded. Keeping the same URL with cache management headers can lead you to a world of pain due to different client implementations.
If you put cache control headers (last-modified, expires, ETAG), you cannot be sure that the CSS will be updated after changing it:
- because aggressive browser caching (or proxies) can ignore them.
- since you can service V1 on May 1, with an expiration date on June 1, upgrade it to V2 on May 15, and your customers will have to wait 15 days to get the new version.
In the case of a URL hash, the worst case scenario is that the client does not cache your css, but the user interface does not change, as it always gets the latest version.
With the expiration date or the last modified date, the worst case is that the client receives the old version and this will change the user's work :)
source share