Skip to content

Cache Busting for Static Assets #4745

Answered by sbwalker
mdmontesinos asked this question in General
Discussion options

You must be logged in to vote

As a developer of a module, you obviously know when one of your static dependencies has changed ie. a CSS or JavaScript file. If you want to ensure that it gets reloaded you can append a querystring to the Resource reference in your code:

            Resources = new List<Resource>()
            {
                new Resource { ResourceType = ResourceType.Stylesheet, Url = "~/Module.css?v=12345" }
            }

This approach works well and is much more efficient than imposing a large overheard on the framework itself to compute and manage versions for every static asset - including those that rarely/never change.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@mdmontesinos
Comment options

Answer selected by mdmontesinos
Comment options

You must be logged in to vote
2 replies
@mdmontesinos
Comment options

@sbwalker
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants