2

i am curious about an issue that i am facing at the moment with Azure CDN and i don't have an answer for it. So, i have a CDN profile and endpoint configured to cache some content stored in a storage container. In the cache behavior, i am using default (ignore query strings). So i modified one file in the container, and i was able to retrieve the modified file from the container, but not from the CDN edge since the edge was returning the previous cached version of the file. So i proceed with the purge of the file in the CDN, and after the purge, i was able to get the modified version of the file. But, if i request the file to the cdn edge with any querystring parameter, i get the original version of the file, instead of the modified version of the file.

Example requesting the file via edge:

w/o qs: https://#storage_account#/#file_path#/hh.min.css -> It gives me the modified version
w qs: https://#storage_account#/#file_path#/hh.min.css?v=0.5 -> It gives me the original version
w qs (2): https://#storage_account#/#file_path#/hh.min.css?a=b -> It gives me the original version

Any idea why this is happening? Thanks.

Hugo Barona
  • 1,303
  • 9
  • 21

1 Answers1

3

Most likely what's happening is the use of the query uses a cached asset, as mentioned per the documentation

Ignore query strings: Default mode. In this mode, the CDN point-of-presence (POP) node passes the query strings from the requestor to the origin server on the first request and caches the asset. All subsequent requests for the asset that are served from the POP ignore the query strings until the cached asset expires.

So my guess is the cached asset did not expire yet. To avoid this issue, you should consider bypassing the caching for query strings:

Bypass caching for query strings: In this mode, requests with query strings are not cached at the CDN POP node. The POP node retrieves the asset directly from the origin server and passes it to the requestor with each request.

If the above option results in latency, I'd recommend adjusting the caching rules.

  • Yah actually you are right about the caching. So apparently there was a version of the asset cached for a url without query string, and another for a url with query string. So even when i forced to purge the asset from the cache, using the url without query string, it did not purge the one with query string. But if the mode is set as default to ignore query string, then it should not cache the object and associate it with the specific URI and query string, right? – Hugo Barona Jul 30 '18 at 16:12
  • Currently the behavior is gone, so if i request the item, via the cdn endpoint, with or without querystring, i get the same item version. In terms of changing the mode to bypass the query string, i can't do this for performance reasons. The CDN is caching assets and delivering them to clients in different locations - worldwide. So i need the georeplication to the cdn edges feature in order to the client consume the assets from the edge and do not consume it directly from the origin. – Hugo Barona Jul 30 '18 at 16:17
  • you're right Hugo, if there are performance issues, I'd recommend playing with the caching settings (TTL), depending on how often you update the files. Glad this helped. – Adam Smith - Microsoft Azure Jul 30 '18 at 16:21