0

As developer, you want all the time the last version files on page refresh action. As I understood, there are 3 kinds of cache :

  1. Browser cache (Browser settings)
  2. Website cache (WP plugins)
  3. Proxy cache (HTTP Headers)

For some reasons, there are some days where I can removed browser cache, download a new browser on Wordpress project without any cache plugin... If I keypress F5, CTRL+F5 or CTRL+Shift+R, I got an old version, sometimes version older. I can loose hours like this. One friend told me to see about the proxy cache and force the HTTP Header to get the last files version.

I got this raw header :

GET /preprod/sign-up/ HTTP/2
Host: mysite.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: ...
DNT: 1
Connection: keep-alive
Cookie: wordpress_test_cookie=WP+Cookie+check; bid_1_password_protected_auth=1111111111111111111111; SERVERID123456=1234
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache

Questions :

  1. How can I check if it can be a proxy cache matter ?
  2. How can I resolve that in this case on a Wordpress site ?
  • Keep in mind that hosting issues, and 3rd party plugin support, are both offtopic here, and there is little that can be done in the generic sense. You've bought into various plugins and technologies that have solutions and expertise unique to those plugins and technologies. You would get more useful answers at their support routes and in their community forums/groups than on a general WP Q&A site or forum – Tom J Nowell Jul 20 at 18:16
2

If it's browser cache, you can go into the dev tools and disable all local cache. Browser docs can tell you how to do this.

If it's the proxy cache, either turn it off or load the site without the proxy, and retest. You will need to consult the documentation for the proxy you're using for how to do this, and how to fix it. You would be better asking on another stack about your specific proxy software and its configuration.

If it's the WP cache, then no, WP doesn't have a page cache. Either disable the plugins providing caching and retest, or consult with their documentation. The solution here will be plugin specific, there is no generic WP solution as there is noo generic WP page caching.


Either start with browser cache and work by peeling away the layers in a process of elimination. Or, by eliminating all of it, and turning it back on 1 layer at a time until the misbehaviour returns. This will give you useful information on how to debug the problem and which layer is problematic.

| improve this answer | |
-1

I found a solution here.

function add_header_no_cache($headers) {

    $headers['Cache-Control'] = 'no-cache, no-store, must-revalidate, max-age=0'; 
    $headers['Pragma'] = 'no-cache';
    $headers['Expires'] = '0';

    return $headers;     
}
add_filter( 'wp_headers', 'add_header_no_cache_login' );
| improve this answer | |
  • Note that this may prevent all caching at all layers for all users – Tom J Nowell Jul 20 at 19:50
  • Yes, in my case I wrapped by if( WP_DEBUG )... – J.BizMai Jul 20 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.