• Resolved nsjana93

    (@nsjana93)


    Hi the Cloudflare cache not working when i enable Varnish Cache getting cf-cache-status: BYPASS

    getting cache-control: no-store, no-cache, must-revalidate, max-age=0

    i have configured the provided the nginx config provided by the plugin

    I am using cloud panel, and there is no issue when I turn off Varnish

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    The plugin does not cache control to nocache when varnish is being used. Can you share your site URL so that we can dig a bit deeper into it?

    Thread Starter nsjana93

    (@nsjana93)

    https://www.bongdunia.com/

    HTTP/2200

    date: Tue, 03 Sep 2024 11:15:32 GMT

    content-type: text/html; charset=UTF-8

    vary: Accept-Encoding

    x-wp-cf-super-cache: cache

    x-wp-cf-super-cache-active: 1

    x-wp-cf-super-cache-cache-control: s-maxage=31536000, max-age=60

    x-wp-cf-super-cache-cookies-bypass: swfpc-feature-not-enabled

    last-modified: Mon, 02 Sep 2024 22:48:41 GMT

    x-cache-lifetime: 604800

    x-cache-tags: 3743,3743-post-49969

    referrer-policy: same-origin

    alt-svc: h3=":443"; ma=86400

    x-cache-age: 44810

    pragma: no-cache

    expires: -1

    cache-control: no-store, no-cache, must-revalidate, max-age=0

    cf-cache-status: BYPASS

    server: cloudflare

    cf-ray: 8bd5528e4926d3b0-FRA

    Plugin Contributor iSaumya

    (@isaumya)

    As you can see above the values of x-wp-cf-super-cache-cache-control and cache-control does not match. Which means you may have some other page caching plugin or system that is overwriting the cache-control header.

    Thread Starter nsjana93

    (@nsjana93)

    The cache-control: no-store, no-cache, must-revalidate, max-age=0 appearing when I enable varnish cache

    Plugin Contributor iSaumya

    (@isaumya)

    Then maybe some varnish plugin is getting added to your website that’s adding that cache control header?

    Thread Starter nsjana93

    (@nsjana93)

    no i have only wp-rocket and Super Page Cache

    but i have found header(sprintf(‘Cache-Control: public, max-age=%s, s-maxage=%s’, $cacheLifetime, $cacheLifetime)); line in varnish settings.json file

    public function sendCacheHeaders(): void
    {
        $isCacheable = $this->isCacheable();
        if (true === $isCacheable) {
            $cacheTagPrefix = $this->getCacheTagPrefix();
            $cacheLifetime = $this->getCacheLifetime();
            $cacheTags = array_merge([$cacheTagPrefix], self::getCacheTags());
            $cacheTags = array_unique($cacheTags);
            if (count($cacheTags)) {
                header(sprintf('X-Cache-Lifetime: %s', $cacheLifetime));
                header(sprintf('X-Cache-Tags: %s', implode(',', $cacheTags)));
                header(sprintf('Pragma: %s', 'cache'));
                header(sprintf('Cache-Control: public, max-age=%s, s-maxage=%s', $cacheLifetime, $cacheLifetime));
            }
        }
    }
    Thread Starter nsjana93

    (@nsjana93)

    also found set resp.http.Cache-Control = “no-store, no-cache, must-revalidate, max-age=0”; in file

    set resp.http.X-Cache-Age = resp.http.Age;
    unset resp.http.Age;
    
    # Avoid being cached by the browser.
    if (resp.http.Cache-Control !~ "private") {
      set resp.http.Pragma = "no-cache";
      set resp.http.Expires = "-1";
      set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
    }
    Plugin Contributor iSaumya

    (@isaumya)

    Yes that’s the file. From where it’s coming from? Can you share the file path?

    Thread Starter nsjana93

    (@nsjana93)

    /etc/varnish i removed the code and now its working

    Plugin Contributor iSaumya

    (@isaumya)

    Amazing… Great to hear that…..

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘cf-cache-status: BYPASS with Varnish Cache’ is closed to new replies.