Ensuring Updated CSS/JavaScript on Client Side

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2009-09-19T07:23:09Z Indexed on 2010/05/31 1:52 UTC
Read the original article Hit count: 221

Filed under:
|
|

I'm trying to ensure that visitors of my ASP.NET MVC website always have the most-current CSS and Javascript (and not some older cached version).

I tried to realize this by generating a seed value when the application domain starts, and automatically append it to the CSS and Javascript URLs (so now instead of /Content/All.js the link is /Content/All.js?549238 etc.).

Unfortunately I just found out by debugging via Firebug that this causes now a full download request every time (the new "seeded" response is no longer cached at all, but I only wanted the first check to download the 'updated' version, but then cache again/only check if there is a difference).

How can I achieve my goal, is there a better way of doing this? I need the client to always request the newest version, but then cache if no change happened.

Edit: This appears to be related to the fact that my page is served over SSL. I asked a follow up question here regarding enabling clientside caching with SSL.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css