Using cache everything but CF-Cache-Status is BYPASS

Hi, I have two page rules:

    Forwarding URL (Status Code: 302 - Temporary Redirect, Url:$1)

    Cache Level: Cache Everything

The redirect works, but the cache everything doesn’t work.
And the response header shows CF-Cache-Status: BYPASS

I don’t know where goes wrong?

ps, my website framework is laravel, but I only build very basic CRUD pages.

Thank you!

make the 2nd url as* instead of just* and make sure the record is proxied. Or if you want both https to be also cached, use ** as your second pagerule URL.

I try to use **, but it still BYPASS, should I need to do another setting? Thank you.

And, when I use*, there is an error:

Your URL contains a reference to an invalid host " http"

Do I set something wrong?

Let me tell if you use HTTPS do the following.
Fisrt rule:

for url:* to$1 using 301 for better SEO for

Second rule:

for url:* use Cache Everything.

1 Like

Yes, I use HTTPS on the whole site, but after I change to these settings, it still shows BYPASS.

Here are the Caching messages shows on the RedBot, I don’t know if they help:

  • This response only allows a private cache to store it.
    The Cache-Control: private directive indicates that the response can only be stored by caches that are specific to a single user; for example, a browser cache. Shared caches, such as those in proxies, cannot store it.

  • This response cannot be served from cache without validation.
    The Cache-Control: no-cache directive means that while caches can store this response, they cannot use it to satisfy a request unless it has been validated (either with an If-None-Match or If-Modified-Since conditional) for that request.
    This response doesn’t have a Last-Modified or ETag header, so it effectively can’t be used by a cache.

Is there a way to debug this? It seems the cache settings are correct. Maybe there are other settings conflict with them?

Thank you.

switch on developement mode and try.

1 Like

Thank you eldhose.

After I set my website to Cache-Control: public, max-age=2628000, and add another rule Edge Cache TTL: 4 hours with Cache Level: Cache Everything, it works! :tada: :tada: :tada:

According to Customizing Cloudflare’s cache and the question from StackExchange:

Resources that match a Cache Everything Page Rule are still not cached if the origin web server sends a Cache-Control header of max-age=0 , private , no-cache , or an Expires header with an already expired date. Include the Edge Cache TTL setting within the Cache Everything Page Rule to additionally override the Cache-Control headers from the origin web server.

If the Cache-Control header is set to “private”, “no-store”, “no-cache”, or “max-age=0”, or if there is a cookie in the response, then Cloudflare will not cache the resource.

Laravel default response is Cache-Control: no-cache, private, no wonder the Cache Everything didn’t work.

According to Customizing Cloudflare’s cache and Understanding and Configuring Cloudflare Page Rules:

When combined with an Edge Cache TTL > 0 , Cache Everything removes cookies from the origin web server response.

So, I need to clean the cache on the server(actually I still don’t know what it is and why I need to do this). Anyway, after I add another rule Edge Cache TTL: 4 hours, it works.

Here are links of how to set to Cache-Control: public, max-age=2628000 in laravel:

  1. Use cache.headers in your route
  2. Make sure cache.headers is in your routeMiddleware

good to hear it works for you. :orange:

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.