9
votes

I'm playing with Azure Static Web Site (new feature of storage account).

This works well for servicing files. However, I didn't found where I can set cache control headers (if it's possible).

Basically, I want to set no expire cache to static bundled javascripts (hash of files are in file name), but not on html pages.

How to reach my goal ?

PS: I'm not using Azure Web Sites, but Azure static web site option of blob storage. Unless web.config are supported (but I don't think it is), do not redirect me to web.config solutions.

1

1 Answers

12
votes

In Azure Storage Explorer, there is a property named CacheControl which you can find in any blob properties. If you set the CacheControl property with a value like max-age=100 as Fig 1 below, you can see it whether be enabled via browser debug tools like Chrome Chrome Developer Tools F12 as Fig 2 below.

Fig 1. Set the value of CacheControl property of a blob index.html enter image description here

Fig 2. Open Chrome Developer Tools to find my setting for index.html above enter image description here

So you can set cache control header for few blobs via Azure Storage Explorer, or do the same in programming for a large number of blobs, as the answer of SO thread Add Cache-Control and Expires headers to Azure Storage Blobs said.