'Azure CDN with SAS token caching mechanism

I have a blob container with restricted public access. Azure CDN is set up on top of it. Please find the below example

Cache Duration: 24 hours

Azure Storage URL: http://azstorage5.blob.core.windows.net/images/img15.jpg

CDN Endpoint: http://az507925.vo.msecnd.net/

Azure Storage SAS parameter: ?st=2020-12-07T19%3A21%3A09Z&se=2020-12-08T20%3A21%3A09Z&sr=c&sp=r&sig=STTE1p0ujzZr31ZjPaOlNoImCPcjss2GoRsOWDlpJuI%3D

Final CDN URL: http://az507925.vo.msecnd.net/images/img1.jpg?st=2020-12-07T19%3A21%3A09Z&se=2020-12-08T20%3A21%3A09Z&sr=c&sp=r&sig=STTE1p0ujzZr31ZjPaOlNoImCPcjss2GoRsOWDlpJuI%3D

If I set cache behavior as Ignore query strings in the CDN

Question: For the first time when tried to access the image img15.jpg, it will be retrieved from blob container and is cached in CDN. If I access the img15.jpg multiple times with different valid SAS tokens within the cache expiration(24 hours) period, will it be served from cache or will it fetch from blob container for every unique valid SAS token?

End Goal: I want the image to be cached on the CDN and should be able to access it with valid SAS tokens but without hitting the blob container as long as the cache is not expired. Is this a possible use case scenario?



Solution 1:[1]

if you configure CDN to cache every sas string, this is expected that files won't be cached, because for CDN they are different files.

if you configure to ignore the sas string, this will end up with unauthenticated users getting access to cached files (just omit parameters, or paste garbage there).

The solution here is to properly construct sas string.

You can give the same parameters for the file do all the clients today: access start time 00:00 today, end time the end of next day.

This will let all the clients requesting file today to have cached copy, and one day ahead to complete download.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman