How to fix X-cache: Miss from Cloudfront

Fixing Cloudfront miss can be a time-consuming task. But, if you are receiving “Miss from Cloudfront” this is usually because of the headers sent from the origin.

Cloudfront caches content based upon the header sent from the origin. To resolve this we first need to identify the headers being sent. This is an easy process by opening Chrome developer tools and viewing the network tab to retrieve the list of headers:

 

In the screenshot above, the page is sending two important headers:

cache-control this tells Cloudfront how long this page should be cached in seconds. In our example it’s 100 seconds.
expires This tells Cloudfront when should the page be expired.

But we are still receiving a “Miss from cloudfront”.

This is because of the “pragma header“.

Cloudfront considers pragma as a valid header and respects it! To resolve and let Cloudfront cache the page we need to either remove the “pragma” header or set it to “public“.

 

 

 

 

 

 

 

I’m a passionate engineer based in London.
Currently, I’m working as a Cloud Consultant at Contino.

Aside my full time job, I either work on my own startup projects or you will see me in a HIIT class 🙂