Reputation: 960
I'm constantly uploading new versions of a javascript file to my wordpress site using ftp.
But when I visit the page where the javascript file is used, it uses an outdated version of the javascript file. An example of url of the used file:
myurl.com/../js/my_file.js?ver=919004c7f6ced.....8f8941dfa68c2e
But if I directly go to the file using myurl.com/../js/my_file.js
it shows the most up to date version.
I'm assuming this is caused by something that's caching my files. I already tried deleted the cache of my cache plugin and I've deactivated it, but it's still using outdated versions.
How can I force my website to use the most up to date version for certain files?
Upvotes: 3
Views: 2838
Reputation: 14312
A bit of background first: The ver
on the included file tells the browser what version to use, and if it already has that version loaded it will use the cached version. This is what you are seeing here - even though you have added a new js file, the browser is still using version 919004c7f6ced.....8f8941dfa68c2e
.
This version is specified in the HTML for the page (i.e. not the js file) so it is the page that is getting cached
There are a number of possible causes for this:
CACHING
CODE
wp_register_script
or wp_enqueue_script
- both of these functions let the code specify what version to use. You should check the code that is creating the version number for the following:Temporary Workaround for Testing: If you just want to test the new script immediately, you could rename the file and change the name in the wp_enqueue/register_script function - obviously this isn't a long term solution, but it can help if you need to test something or make it available immediately without all users having to wait for the cached file to be changed.
Disable Cache in Chrome for Debugging Only If the problem is only the browser cache, you can disable the cache in Chrome while you are debugging:
This will disable the cache only while DevTools is open so it won't affect anything else. Thanks to Daan for this link: How to Completely Disable Cache in Google Chrome
Upvotes: 2