Support » Plugin: W3 Total Cache » 404 pages return 200 OK status header

  • I’m having the following problem:

    I’m using W3Total cache + Cloudflare. I recently found out that there’s an issue with the status headers of the 404 urls.

    For example, after cleaning of all plugin caches and the Cloudflare cache, and testing an already removed url with a redirect checker, the first check shows always 404 and the second, incl. all next checks – 200 OK is returned. It’s the same with each 404s. I tested numerous times.

    A better description of my issue by another person in the past:
    “[caching plugin] is disabled. I visit a known bad link on my site (https://example.com/xyzz/) and receive a 404 error page. I can verify in Chrome’s Inspector and/or Firebug that the “404 Not Found” status is being properly served in the HTTP headers. An online redirect checkers shows a proper 404 status.

    I turn [caching plugin] on and visit the same URL. On the initial visit I am served a cached page (verified by the debugging comments inserted by the plugin at the bottom of the HTML source) with the proper “404 Not Found” status in the HTTP header.

    If I visit the page again (https://example.com/xyzz/), I’m served the same cached page from #2 above displaying the “404 – Page Not Found” error to the user, but with a “200 OK” status in the HTTP header.

    If I turn [caching plugin] off and visit the page again, I am again being served an uncached page with the correct “404 Not Found” status in the HTTP header.

    Any idea what might be going on here? This is seems to be causing some an issue where Google Bot is attempting to index some non-existent pages because its seeing the “200 OK” HTTP header instead of the proper 404.”

    Source: https://wordpress.stackexchange.com/questions/12764/getting-soft-404-errors-200-status-when-caching-plugins-are-enabled

    W3Total settings can be seen here: https://imgur.com/MHhW7G8

    Cloudflare settings:
    Caching Level: No query string
    Browser Cache Expiration: Respect existing headers

    WordPress, Redirection plugin, W3Total cache plugin – all updated to the latest version. Newspaper version: 9.5

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

    (@vmarko)

    Hello @ayo-1,

    Check the Performance>Page Cache if the “Cache 404 (not found) pages” option is enabled. As you can see in the description, If the disk enhanced method of disk caching is used, 404 pages will be returned with a 200 response code. Use at your own risk.

    It’s not checked. You can see my settings here: https://imgur.com/MHhW7G8

    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,
    I can see what you have enabled in your General settings. Can you check the Performance>Page cache, General sub-box?

    Please see here: https://imgur.com/sXKfE4m

    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,
    Thank you for the provided screenshot. Can you please check if the cache entry is created for that page?

    You can try any non-existing url: bit.ly/2QwcAH8

    The first check returns 404 and the second, third etc. checks return 200 OK. It’s the same with all removed urls.

    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,
    Are you using any other caching solution except W3 Total Cache?

    I’m using Autooptimize and Cloudflare, but I isolated the issue to W3Total. It doesn’t happen when I turn W3Total off.

    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,
    Pages are cached, not assumed as 404.
    That means that you have option “cache 404” enabled or your website works such a way that is_404() wp call returns false for 404 pages which is not correct. As a result, W3 Total Cache doesn’t know its 404 and caches it.

    The issue turned out to come from incompatibility between the plugin “404page – your smart custom 404 error page” and W3Total cache.

    When W3Total is switched off, the 404 plugin works well.

    When the 404 plugin is switched off and W3Total is on, things work again.

    When both plugins are switched on – things go wrong.

    Any ideas how can I fix this?

    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,
    You can simply exclude those pages from the cache in Performance>Page cache, scroll down to advanced and add the pages to Never cache the following pages: text-area.

    Not a solution for me as there are hundreds of pages that are being removed every month.
    I’ll find another solution.

    Thanks for your time and support!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘404 pages return 200 OK status header’ is closed to new replies.