1
votes

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

https://gtmetrix.com/reports/mydoginsurance.com.au/TpxI5hxs/ 19 resources not using CDN:

Initially I used the Cloud CDN configuration of "Cache Static Content". But upgraded this 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

I "think" this may be due to nginx and what is a "static" image.

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

UPDATE:

The cache seems to exist, its just too short and I can't seem to extend it. the CDN says its only caching these images under a 50min cage policy, but I've set htaccess to 1 year.

image cache is saying its only set to 50min

2

2 Answers

1
votes

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.

1
votes

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.