15
votes

I have an ASP.NET MVC4 application that (I think) has been working correctly with JavaScript and CSS bundling since it was first published one year ago. During that period, we have published numerous updates and seen no evidence of problems with script delivery.

However, with our latest code deployment, I noticed that the served JavaScript is not up-to-date and that the querystring parameter used in the request for the script bundle does not change, regardless of changes to the underlying script content.

I have tried rebuilding the solution in Visual Studio and verified that the modified script files are being correctly deployed to the server. I have also explicitly recycled the IIS application pool and restarted the server, but the problem persists.

Any ideas how to diagnose or fix this issue please?

UPDATE: Having just compared the staging and production servers, I notice a difference in behavior. Both servers are deployed to in the same manner, using Visual Studio web deploy. The staging server correctly and immediately reflects changes to script files, by updating the hashes that it uses in the URLs that reference script bundles. In contrast, the production server fails to update its bundle hashes in response to script file modifications and/or changes to the composition of script bundles (even after restarting IIS or recycling the application pool). This suggests that the problem is isolated to the production IIS environment, and is not related to my code changes or Visual Studio configuration.

2
You have checked initially it's not a caching issue? You haven't give much detail to go on, have you confirmed the bundles contain the scripts you expect and there are no duplicates?Lotok
I would still check if that's not just some "user error" one. The bundling is not really related to MVC - that's another MS component. I've recently used it with winforms as well. Everything works like a charm.Agat
@James: I am happy to provide more detail if you can suggest what I should look for. I am not sure how to check whether it's a caching issue. I have confirmed that the HTTP responses to bundle requests contain the old versions of the scripts (in minified form). Where else should I look and what should I be looking for?Tim Coulter
@Agat: I agree, it also worked well for me until now. However, this is not a user error. I've seen for myself that the scripts delivered in response to a bundle request are out of data. More significantly, the request querystring is also not updated when the script content changes.Tim Coulter

2 Answers

19
votes

After a lot of searching, I eventually stumbled upon the cause of this problem.

The failure of the server to detect newly deployed changes to JavaScript files was caused by a few similarly-named minified versions of these JavaScript files existing on the server. I assume this behavior is by design, namely that the bundling process gives preference to an existing minified file and ignores an equivalent un-minified file, even if it is newer.

I can't be sure exactly how these few minified files came to be on the server, but I assume they were the result of an experiment involving some alternative form of minification/bundling. In any case, simply deleting them allowed the bundling mechanism to see my deployed script files and everything started working.

0
votes

I think there might be an issue with ASP.NET cache dependencies and read only files on disk, can you check if your files end up read only in your deployment environment?