skip to Main Content

Site running Google Cloud CDN –
According to numerous test is not Caching webp images – potentially all images.

This was corroborated with GTMetrix.

Initially, I used the Cloud CDN configuration of "Cache Static Content".
and later upgraded to "Use origin settings based on cache-control headers"
Current Cache Settings:

I am still seeing images, particularly webp not being cached by CDN.
I have also updated the .htaccess file to increase the TTL for webp.

Htaccess images TTL

How can I get these images cached properly in cloud CDN?

2

Answers


  1. That GTmetrix report is simply wrong. They apparently don’t correctly detect use of Cloud CDN. I see cache hits from Cloud CDN for images such as /images/banner.webp.

    There’s information on troubleshooting cache misses at https://cloud.google.com/cdn/docs/troubleshooting-steps#responses-not-cached that you can use to double check.

    Login or Signup to reply.
  2. Just adding to elving‘s answer – the report is wrong – your site is using CDN for images too.

    I’ve fallowed official documentation on troubleshooting GCP’s CDN.

    Just run curl -s -D - -o /dev/null https://mydoginsurance.com.au/images/banner.webp and you should get:

    HTTP/2 200
    server: nginx
    date: Thu, 25 Feb 2021 12:26:01 GMT
    content-type: image/webp
    content-length: 130564
    last-modified: Fri, 16 Oct 2020 10:12:50 GMT
    etag: "5f897222-1fe04"
    x-powered-by: PleskLin
    accept-ranges: bytes
    via: 1.1 google
    cache-control: max-age=86400,public
    alt-svc: clear
    

    and when I ran it again a few minutes later:

    HTTP/2 200
    server: nginx
    date: Thu, 25 Feb 2021 12:26:01 GMT
    content-type: image/webp
    content-length: 130564
    last-modified: Fri, 16 Oct 2020 10:12:50 GMT
    etag: "5f897222-1fe04"
    x-powered-by: PleskLin
    accept-ranges: bytes
    via: 1.1 google
    age: 223
    cache-control: max-age=86400,public
    alt-svc: clear
    

    Third last line is age: 223 which means that this reponse was served from cache created 223 seconds ago;

    The last response in this example includes an Age header. Cloud CDN adds an Age header to responses that it serves from cache. Here, the header indicates that the response was successfully served from cache by using a cache entry that was created two seconds ago.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search