Using updated CSS files
Some browsers just don't seem to "get" the idea behind shared files like CSS or Javascript files. For a while now I've been uploading updates to a web site and noticing that the browser continues to use the old version.
That's pretty dumb. Caching - wherever it happens - is supposed to keep a copy for speed of access and update itself when the original changes. It seems to me that this just doesn't happen most of the time.
Sure, you can press Ctrl-F5 or Ctrl-R to reload the page and get all the latest files, but what if you don't know you have to? Users of the site can see strangely broken sites when the markup and css don't match. Most have been conditioned now to refresh (I hope anyway), but why doesn't it get fixed?
In any case, I added some code to the site so that the timedate of the file in question is added to the URL, like this:
<link rel="stylesheet" href="common.css?Filedate=633141635220000000" type="text/css" />
Since everyone at least caches by URL, now the cache is forced to update whenever the file changes. A tidied version of this will appear in Community Server at some point I think I heard. Lots of people use this method, it's not new, but my method appends a "version number" automatically by using the file datetime - making it zero maintenance.
But there's still a big problem.
I realized yesterday (one of those duh moments) that this isn't as foolproof as I'd hoped. This only works with the CSS files that we include in our web pages, not the ones that the CSS files themselves include.
If, inside my common.css there was a line like this..
@import url("./style.css");
..then we're still screwed. style.css will only be refreshed whenever the time of day is divisible by 7 or whatever silly rule the browser decides to use. Setting CSS files to expire regularly in IIS seems equally dumb, but at least it's foolproof. Thoughts?