We help IT Professionals succeed at work.

Content expiration best practices

I'm wondering if I can get some advice on how everyone out there is handling content expiration for e-commerce sites. I'm running into some issues now and then that I think are caused by the user not getting the newly-fixed script files when they come to the site. I have used the querystring method of "file.js?v=123" in some places, but for some includes, it's not practical to change it on every page it's included on. I'm looking into the content expiration settings in IIS, but am wondering the tradeoff of the user having to download the script again for every page. Some of our script files are pretty large, so load-time is a concern. How can I get the best of both worlds where the user can load a cached version but make sure they get the new version as soon as it's uploaded?
Comment
Watch Question

Commented:
You are correect that it is common for *big* traffic sites it works this way especially common in their CDN setuups

For each peice has a different file name for each version number

That way you always get different content each time for the users.

However as you have discovered this is a lot of work. You need a whole infrastructure in place and detailed release management and you need to do it for all content for consistancy.

The other way is for content expirary to be fixed period like 1 week, etc and after that time it retries.

As this is stored on the client so there is nothing you can do about it. The client will remember and only check if there page has expiried.

So to answer you question:
"How can I get the best of both worlds where the user can load a cached version but make sure they get the new version as soon as it's uploaded?"

No sadly, you cannot do this. It is one of the other ways of doing it. Changing the server content (in your case version numbers), a lot of work - OR changing client retaining period before checking again. You cannot mix them sadly.