Google Cloud CDN strips CDN query string parameters URLPrefix, Expires, Signature and KeyName

195 Views Asked by At

Today I noticed that my signed image URLs through Google Cloud CDN are not working any longer on production.

What I did to debug:

  1. Added debug logging to the application to see what query string is coming in and noticed that the query string was missing.
  2. I then compared a direct origin request with a CDN request and noticed that the direct request had the parameters in the Google Cloud log and CDN request was missing those.
  3. I then googled for other people having this issue and found only one hit, and it was posted a week ago: https://www.googlecloudcommunity.com/gc/Infrastructure-Compute-Storage/CDN-is-removing-signed-URL-query-parameters-and-not-caching/m-p/609210

The interesting part is that this person has the EXACT same issue as me that the code works on one environment/cdn/project but not on the other.

  1. I then added a query parameter before the URLPrefix and noticed that that one was passed on to the origin server just like the person above mentions.
  2. I tested from different browsers and curl, still same result
  3. I tested on our test environment (different GCP project) with the same code and proxy setup and there it works fine (same like the person from the URL above mentions).

I wonder if anybody else experiences this issue and if it was resolved some how. I also reported the issue to Google Cloud

1

There are 1 best solutions below

1
Yvan G. On

I found this public issue tracker wherein it was reported as “Issues caused by query strings being ignored by Google Cloud CDN” then it was recommended to still use the content delivery best practices.

The behavior is intentional to improve the cache hit ratio and reduce the number of cached variants of resources. Cloud CDN removes query params in URL for caching purposes. Let me also share this link wherein this concern was reported and mentioned that the workaround is using custom cache keys.