Search code examples
cachingcloudflare

How to bypass Cloudflare cache for POST request?


I'm troubleshooting our WooCommerce Reset Password Link as it's not sending the password reset email and suspect caching is the issue. I have the following caching enabled:

  1. Cloudflare
  2. WP Rocket

Under Cloudflare, I have the following rules:

  1. https://www.example.com/my-account/*
    • Cache Level: Bypass, Disable Apps, Disable Performance

Headers:

I see that the cache is bypassed when visiting the pages by inspecting the headers and seeing cf-cache-status: BYPASS, but when I submit the email to send the password, I see the following HTML requests:

302    POST   example.com    /my-account/lost-password/    (header says cf-cache-status: DYNAMIC)

and

200    GET   example.com    /my-account/lost-password/?reset-link-sent=true    (header says cf-cache-status: BYPASS)

My question is: is this first POST Request (302) normal behavior with the Page Rule I have set up? I'm just trying to debug why reset password emails will not send at all.

I believe WP Rocket bypasses Woo pages by default. Thanks for any insight!


Solution

  • The DYNAMIC status means that the request handling never checked cache in the first place, because the request was a type that cannot be cached. In particular, POST requests cannot be cached (only GET and HEAD can be).

    The 302 response code is not related to caching and is probably legitimately what your origin server returned. It's pretty common for web apps to respond to successful POST requests with a 302 redirect.