3

I've set up an Azure CDN using the Standard Akamai tier. My origin is a Web App. I've set up the cache-control header in my web.config as follows:

<clientCache cacheControlMode="UseMaxAge" cacheControlCustom="public" cacheControlMaxAge="30.00:00:00" />

In my markup, I'm hitting my image file with the following code:

<img src="https://xxxx.azureedge.net/Content/Images/Turtle.jpg?v=1.0.0.27987">

When I do so, I get the following response headers:

cache-control:public, max-age=2591903 
content-length:2321435 
content-type:image/jpeg 
date:Mon, 03 Apr 2017 19:34:23 GMT 
etag:"2e7a1f1690a9d21:0" 
last-modified:Thu, 30 Mar 2017 19:59:05 GMT 
pragma:no-cache 
server:Microsoft-IIS/8.0 status:200 vary:Accept-Encoding x-powered-by:ASP.NET

Notice the pragma:no-cache. I have NO IDEA where that is coming from. This is definitely NOT in my origin's response to load the cache. If I hit the origin, I see the following headers sent for the same image:

Accept-Ranges:bytes
Cache-Control:public,max-age=2592000
Content-Length:2321435
Content-Type:image/jpeg
Date:Mon, 03 Apr 2017 19:41:50 GMT
ETag:"2e7a1f1690a9d21:0"
Last-Modified:Thu, 30 Mar 2017 19:59:05 GMT
Server:Microsoft-IIS/8.0
X-Powered-By:ASP.NET

This means that when hitting the CDN, instead of serving this image from http cache, it's sending the ETag and I'm wasting a HTTP roundtrip. I'm assuming that the culprit is the pragma:no-cache header that is sent, which is overriding the cache-control header. My questions are:

  1. Why is the Azure CDN adding this pragma:no-cache header when serving my image?
  2. Is the pragma:no-cache the reason we're seeing the 304/ETag validation instead of serving from http cache?

Thanks!

Edit: I've also tried removing the tag from the web.config. I'm still seeing an ETag transmitted for the image instead of serving it from the browser http cache.

Rob Reagan
  • 7,313
  • 3
  • 20
  • 49
  • If you use chrome to view an image it does not seem to cache. It only attempts to cache when in a page. – Dave Hillier Feb 28 '18 at 20:58
  • This pragma header prevents the icon fonts from displaying in IE with https. Changing the css url() to use the origin solves the problem. – GarDavis Dec 17 '18 at 18:58

0 Answers0