Guzzle HTTP GET requests not caching

Active Subscription: Free Plan

Page Rule:
Maching URL: https://example.com/*

  • Cache Level: Cache Everything
  • Edge Cache TTL: 14 days
  • Browser Cache TTL: a year

I am using two methods to send a GET request to my URLs:

  1. Google Chrome desktop browser
  2. PHP Guzzle HTTP client

HTML response is returned in both cases.

But, HTML response is cached on Cloudflare if I use a desktop browser like Google Chrome and is not cached, when I use Guzzle HTTP Client.

Any clues or ideas on this problem?

Can you capture and share a request with debug = true. Redact your domain name in the response if you need to.

1 Like

Thanks for your answer

  • Trying 104.21.40.247:443…
  • Connected to example.com (104.21.40.247) port 443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  • successfully set certificate verify locations:
  • CAfile: /etc/pki/tls/certs/ca-bundle.crt
  • CApath: none
  • SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
  • ALPN, server accepted to use http/1.1
  • Server certificate:
  • subject: CN=*.example.com
  • start date: Jan 20 13:59:26 2021 GMT
  • expire date: Apr 20 13:59:26 2021 GMT
  • issuer: C=US; O=Let’s Encrypt; CN=R3
  • SSL certificate verify ok. > GET / HTTP/1.1 Host: example.com Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36 do-opt: 1 Upgrade-Insecure-Requests: 1 Cookie: __cfduid=d7ad63725def5a4cdb0fc9e0de1a51b441612824977
  • Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Date: Mon, 08 Feb 2021 22:56:26 GMT < Content-Type: text/html; charset=UTF-8 < Transfer-Encoding: chunked < Connection: keep-alive < Cache-Control: max-age=31536000, s-maxage=31536000 < X-WP-Opt-Cloudflare: cache < X-WP-Opt-Cloudflare-Active: 1 < X-WP-Opt-Cloudflare-Cache-Control: s-maxage=31536000, max-age=60 < X-WP-Opt-Cloudflare-Cookies-Bypass: optimization-Cloudflare-feature-not-enabled < Vary: Accept-Encoding,User-Agent < CF-Cache-Status: HIT < Age: 3 < cf-request-id: 0825755c2900003325ffa40000000001 < Expect-CT: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct” < Report-To: {“max_age”:604800,“endpoints”:[{“url”:“https://a.nel.Cloudflare.com/report?s=dAB%2B6GVterGkC96dUU1kZObboaBp2dKhmJq5zCh%2FtD%2BsvkcWbIqIGRuH9b02%2BIEEc87ZH0MqulCsGY%2FJy%2BtsR%2BFrPJmtA3SG%2B4VqJDc%3D”}],“group”:“cf-nel”} < NEL: {“max_age”:604800,“report_to”:“cf-nel”} < Server: Cloudflare < CF-RAY: 61e8f1a6ab243325-CDG <
  • Connection #0 to host example.com left intact

That seems to show a cached response being delivered. Are you seeing something else?

1 Like

Thank you.

The page itself is cached successfully, but the resources like CSS and JS files are not. Thus page load time is too long

Can you rerun the test on one of the uncached files? Are they served through a hostname which is patched by your page rule? Do they have a CF-Cache-Status response header?

1 Like

Yes they have:

CF-Cache-Status: 1

too.

Would you please check this more detaild explanation of the problem to this point:

Multiple HTML‌ versions are cached for same URL but different user agents

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.