How to Avoid Caching of CSS & JS During Development

Sdílet
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

Komentáře • 9

  • @khatriiaarun
    @khatriiaarun Před rokem

    been thinking about this for a whole day. thank you so much

  • @frannyj
    @frannyj Před rokem

    FANTASTIC Tip. Thanks!!!

  • @leonmarienga3293
    @leonmarienga3293 Před rokem

    Thank you

  • @mohammedfahmy3946
    @mohammedfahmy3946 Před rokem

    thanks for help

  • @sandeshtayde1372
    @sandeshtayde1372 Před 2 lety

    But what if index.html is itself being cached and showing older js and css files ??

    • @danisimeonov4759
      @danisimeonov4759 Před 2 lety

      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.

  • @Itskodaaaa
    @Itskodaaaa Před rokem

    Can you do this with JavaScript... Please

  • @ezraerwindi8063
    @ezraerwindi8063 Před rokem

    The codes are universal for all ?

  • @leonmarienga3293
    @leonmarienga3293 Před rokem

    Thank you