Question

On the website I'm building we are using the built in bundling and minification. We render our scripts by using the @Scripts.Render

@Scripts.Render("~/bundles/scripts")

it generates a link like:

bundles/scripts?v=3-DUUAAegZl4yp1O4V0VL0GnJ0U6gT3De8yKb41lfGs1

Here I thought that the hash:

v=3-DUUAAegZl4yp1O4V0VL0GnJ0U6gT3De8yKb41lfGs1 

would be smart and change if we made changes to the inlcuded scripts but it seems like that is not the case.

Now when we are trying to implement a custom cdn for out bundling it fails on updates since the hash never seems to change.

Does anyone know of a solution to change the hash when the script changes or if we are doing something wring?

Edit: I noticed that there is a difference in behavior depending on what environment I'm using. Local development it seems to be working but it doesn't work on the staging server. Should there be a difference?

Edit2: Seems to be working as it should on production servers as well. Will have to do more research on what the cause can be.

Edit3: Seem that the one causing the problem was in the registry LogRewrittenUrlEnabled was set to false to allow url rewrites at the same time as using dynamic content compression (gzip) so will have to find another way to enable this

Was it helpful?

Solution 2

The problem was that on the server we had in the registry

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Rewrite /v LogRewrittenUrlEnabled set to false

And if you have that then the cache-buster hash is not refreshing when the content i bundle is changed.

OTHER TIPS

You're right, the cache-buster hash should change if you change the contents of a script. There's some useful information about how the cache for bundling works that may help you here ASP.NET MVC Bundling cache. (Detecting css files changes) (internal behaviour).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top