Agreene
Agreene

Reputation: 538

Forcing already set Cache Control Headers to expire immediately

I'm using a third party JavaScript component the it requests some JavaScript files internally. The files are served from the "assets" directory on my site, which has caching set as:

Cache-Control:max-age=864000

which is 10 days.

The issue I'm having is that when I have to release a new version of the third party component, I have no way of expiring the JavaScript files that have been cached for 10 days, so my users will get errors. I realize that one solution is to find a component that allows for a cache-buster, but assuming I can't, is there a way to force all browsers to bust the cache for files that have already been cached by the browser?

Upvotes: 0

Views: 373

Answers (1)

thiagonobre
thiagonobre

Reputation: 61

You can add a query string at the end of file path, for example:

<script src="/path/to/file.js?v1"></script>

Every time you want to change, just increase the version of the file.

Upvotes: 2

Related Questions