• Resolved digikb

    (@digikb)


    Hi,
    I’ve run into a serious issue with WP-Optimize’s Browser Cache feature that causes wp-admin pages to be cached by the browser, which leads to existing posts being overwritten instead of new posts being created.

    Important:
    This behaviour has only started happening recently, despite the Browser Cache feature having been enabled for a long time without issues. Something appears to have changed (perhaps browser behaviour or how the headers are applied).What’s Happening

    When Browser Cache is enabled, WP-Optimize inserts this rule into .htaccess:

    <filesMatch "\.(x?html?|php)$"> Header set Cache-Control "private, must-revalidate, max-age=2592000" </filesMatch>

    Along with ExpiresByType text/html "access 1 month".

    This effectively instructs browsers to cache all PHP output, including admin pages, for up to 30 days.

    As a result:

    • “Add New Post” may load a cached version of post-new.php
    • That cached page contains the previous post’s post_ID
    • Publishing then overwrites the earlier post

    This is reproducible across major browsers.How to Reproduce

    1. Enable Browser Cache in WP-Optimize.
    2. Create Post A.
    3. Click “Add New” → browser may reuse cached page.
    4. Create Post B → Post A gets overwritten.

    Disabling cache in browser dev tools prevents the issue.Workarounds

    • Disable Browser Cache in WP-Optimize (resolves it), or
    • Modify the PHP rule to:

    Header set Cache-Control "private, must-revalidate, max-age=0"

    This stops wp-admin caching while keeping static asset caching.Why This Is Serious

    • wp-admin content must never be browser-cached.
    • Long-term caching of PHP is unsafe for dynamic sites.
    • This results in silent data loss, which is particularly severe.

    Suggestion

    Browser Cache should:

    • Exclude .php, or
    • Exclude /wp-admin/, or
    • Apply only to static assets (CSS, JS, images).

    Given that this issue has only surfaced recently, it would be useful to review whether browser behaviour or plugin logic has changed.

    Happy to provide further info if needed.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Thanks so much for reporting this and providing steps to reproduce. I will test this on some of my sites and see if I can experience the same behaviour.

    One quick question, can you let me know which version of WP-Optimize you are using? We had a release earlier today so I just want to double check.

    Thank you!

    Thread Starter digikb

    (@digikb)

    Hi,

    We are using Version 4.4.0, the latest version, but we also experienced this on the previous version too.

    Also, we have replicated this issue on multiple websites.

    Look forward to hearing back.

    Many thanks

    Thread Starter digikb

    (@digikb)

    Some additional info, we are running PHP 7.4.3 for this particular site. We did test on another site running php 8.1.2, and the issue did not come up. This may not be relevant, but thought I would let you know as this may help with debugging.

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    This is super helpful information! I’ll make sure to run tests on PHP 7.4 as well. Is it possible to update those sites to PHP 8 where you are seeing the info? Not only to resolve this problem but just due to PHP 7.4 having been EOL since 2022.

    I’ll let you know how my tests go!

    Thread Starter digikb

    (@digikb)

    They will be updated soon, but for now it would be good to get a version working with PHP 7.4 as it’s still widely used.

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    So unfortunately on my side I’m not able to reproduce the same behaviour on my site running PHP7.4. I checked and I do still have the same htaccess rules.

    Just to double check, is the web server Apache or Litespeed? I know Litespeed can also use htaccess files so just want to double check.

    Another quick question, the site that wasn’t experiencing the behaviour with PHP8 are they on the same host that you are seeing the behaviour?

    Thank you!

    Thread Starter digikb

    (@digikb)

    To answer your questions, we are running Apache.

    On the php8 site we tested, it is the same hosting environment, but a different server.

    Hope this helps.

    Thank you.

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Thanks for the update! I was testing on an Apache server as well where I wasn’t running in to the issue.

    I think in this case it might be a good idea to modify the htaccess rule in your environment until the update to PHP 8 can happen.

    I also made sure to test this in a number of different browsers but wasn’t able to reproduce the same result as you.

    I’ll keep testing and ask my colleagues if they are able to reproduce the behaviour but this is also the only report we’ve had of this either on the forums or on our premium support platform so it seems to be isolated behaviour.

    One thing that might be different in our setups, does the environment where this is happening use any Object caching such as Redis or Memcached?

    Thank you!

    jjb100

    (@jjb100)

    Hello,

    actually we have exactly the same problem, although we use PHP 8.3 , I just updated to 8.4
    I wrote about that 6 weeks ago.
    I  then disabled the WP-Optimize cache. But the problem persists. And it makes editing posts difficult.
    Perhaps there are other reasons? Indeed we use a WordPress Theme, that needs updating.

    My post: https://wordpress.org/support/topic/cache-works-exceptionally-well/

    @jjb100 @digikb are you also hosting your websites with Strato? https://wordpress.org/support/topic/php-cache-for-logged-in-users/ mentions the same problem specifically with Strato hosting, where I’m having the exact same issue as well.

    Thread Starter digikb

    (@digikb)

    No we are not. Its not an issue related to a specific host as far as I am aware. I recommend you just disable Static file headers, then clear your browser cache. There is only has a marginal gain on performance and ultimately stops a really serious problem.

    Hopefully they get a fix for this as it’s been going on for some time with multiple users reporting it.

    @digikb Okay, thanks for replying. I already used your suggested fix and that works, thanks for that.

    Would indeed be good if the plugin solves it properly so we can go back to using the functionality again.

Viewing 12 replies - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.