skip to Main Content

I have been searching the web for a while now, looking for a solution how to force a client’s browser to not only clear cached JS and CSS files, but also php generated files? Or maybe it has something to do with the cookie handling…?

My current situation: I am maintaining a custom WordPress Theme and have written a filter function to change the html output for the password form for password protected posts. When applying the changes and changing the theme version, the html output is updated as expected. However, when trying to enter the password the user is then logged out from the website instead of accessing the post…

Opening an incognito tab or clearing the browser cache resolves the issue and everything works as it should. However, I cannot contact all the users and explain to them how to clear their browser cache! Especially since I regularly need to make similar changes on the site as new features are added while it is already in use.

Also noteworthy: the website runs with SuperPWA and most users access the site via an installed version of the PWA on their mobile devices. So disabling this plugin is not an option.

2

Answers


  1. For this purpose on JS / CSS I use the ‘Prevent Browser Caching’ plugin and it works great.
    About clearing generated PHP… Are you using a caching plugin? Remove it!

    Login or Signup to reply.
  2. You need to set the assets’ Cache-Control header value to control how long a network request is cached by the browser.

    If you cache an asset using the service worker then you need to create an invalidation routine that works for your site. There are multiple cache invalidation strategies you can employ. I use a variety of these in the applications I develop.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search