How to Avoid Caching of CSS & JS During Development
Vložit
- čas přidán 9. 09. 2024
- Have you ever made changes to a CSS or JS file but then even when you refreshed the Web site you don't see those changes taking place. It can be frustrating and the culprit is usually caching your web browser is using it cached or downloaded copy of the file instead of actually read downloading and using your newest copy of the CSS or JS file. Let me show you how you can see caching in action in your web browser.
Watch Full WordPress Theme Development Course here
bit.ly/34glNud
==============
IMPORTANT
==============
Education should be FREE but if you can afford it buy course from here
bit.ly/2RkXEgy
#codeplusplus #wordpress #avoidbrowsercaching
been thinking about this for a whole day. thank you so much
FANTASTIC Tip. Thanks!!!
Thank you
thanks for help
But what if index.html is itself being cached and showing older js and css files ??
Hi! I am investigating this same thing for custom project. The solution I came to was this. You need to have the actual version number coming from the backend at all times. A sort of initial request. All subsequent file requests should have that version appended as a url parameter. It adds a single request overhead to make sure that the server version is the same as the cached version. If not, all files will reload the new version, if same, they will load out of cache. The implementation of this (at least for me) was a bit of a process, but that is the base logic.
If anyone can elaborate or tell me of a better solution, please help xD
Note: the service worker API is great for this, but for cases when it is not present (ever decreasing amount of devices and browsers don’t support it), this seems the best and most fool proof way to control when to force the client to reload files from the server instead of cache.
Can you do this with JavaScript... Please
The codes are universal for all ?
Thank you