For a customer project I’m working on at the moment, we are using AWS CloudFront as a Content Delivery Network (CDN) to improve the global performance of a public website. Users in regions far away from the server should be able to view the website much faster thanks to it being cached on a CloudFront edge location close to them.
For our testing, we wanted to know whether a resource (JavaScript, images, CSS, …) is coming from the cache or whether it got loaded directly from the actual origin, the webserver. And of course we didn’t want to know this just for a single file, but for all resources that get loaded when a page is accessed, so that we can confirm how well the CDN is working.
The CloudFront cache status for a resource gets sent along in the X-Cache header. If it is cached, the header will state “Hit from CloudFront”, if it gets loaded from the origin it’ll say “Miss from CloudFront”. If the object doesn’t exist, you’ll see a “Error from CloudFront”. So all we need to do now is to see the X-Cache header values for all resources that get loaded. The perfect tool for this (and many other things, of course) isĀ Fiddler, as it allows us to inspect our web requests very thoroughly – which resources get loaded when a page is opened, HTTP status codes, request and response headers, etc. Best of all, we can see this in a nice tabular view, showing any relevant information we need.
To configure Fiddler to show the X-Cache header value, we need to make a small change to the list of visible columns: Right-click on the list of columns and select “Customize columns”. In the following dialog, select “Request Headers” for the Collection field. Enter “X-Cache” under Header Name and Column Title, and confirm by clicking “Add”.
Once done, we can access our page, and immediately see the results:
As you can see from the screenshot above, nearly all resources came from the CDN (great!), the only resource that had a Miss was configured to be loaded directly from the origin.
Getting AWS CloudFront CDN Cache Status with Fiddler #aws #cloudfront #fiddler https://t.co/kcLOWcceEg
RT @modery: Getting AWS CloudFront CDN Cache Status with Fiddler #aws #cloudfront #fiddler https://t.co/kcLOWcceEg
Getting AWS CloudFront CDN Cache Status with Fiddler https://t.co/JwMNIzNU52 #aws #cloudfront #cache