Difference between no-cache and no-store

The Cache-Control header has no-cache and no-store headers that look very similar and i wanted to figure out what is difference between them so i did few experiments and this is what i found.

I do have a simple Html page on my Apache Server and that page has a static image which is also served by Apache Http Server and i tried setting Cache-Control :no-cache and Cache-Control: no-store header for that image and i used Firefox to find the results.

no-cache

Tells the browser and cache that they cant reuse the content without checking with the originating server first. Ex. If you send no-cache header from the originating server, then the resource will be cached in browser as well as caching proxy, but next time when you request that resource, the cache it will send conditional GET request to check if the resource is changed. If yes then server will send HTTP 200 response, if the resource is not changed it will send HTTP 304 response

Important Note: The no-cache header tells browser that you can reuse the image but you should validate it with the originating server if the resource is actually changed

This is screen shot of my firefox when i tried accessing the sample page



Then i went to the firefox cache information page at about:cache and i looked for the cachesample.gif, and there is entry for the cachesample.gif in diskcache like this



Now whenever i go to the page, the browser makes conditional GET request to the server and since i am not changing image, it always gets HTTP 304 (Not Modified)

no-store

The no-store directive is more strict, it means the response cannot be written to the cache at all. Ex. If you send no-store for a response then cache wont store it at all and next time when it gets request for that resource it will send that request to the originating server, which will send the full response with HTTP 200 status

This is what i see when i try to access the same page, but now apache is configured to return Cache-Control: no-store header



After that i tried searching in the firefox cache configure (about:cache) page but i could not find the entry for the image in disk cache. Also when i go to the page that has this page, it makes a full request, without If-Modified-Since and server always returns full response with body and status code equal to 200.

16 comments:

Anonymous said...

Practically and neatly explained. Thanks!

VIVEK VS said...

Thank you Sunil, It was really helpful.

Anonymous said...

Good and crispy explanation... Cheers buddy

Anonymous said...

images is not place in right description

Anonymous said...

good, it explained clearer than w3.

Unknown said...

Awesome Explanation , Better than Wiki

Abhilash said...

Thanks Sunil. That clears my doubt on no cache.

Anonymous said...

Nice and Awesome...

Sachin said...

Very neat, thank you

Unknown said...

Thanks for this Sunil.

Jeevan Nagaraj said...

Great Explanation! :)

Unknown said...

Very well explained

Anonymous said...

Thanks for the explanation sunil.
Perfectly explained. Helped a lot

Abhi said...

Thanks for info
Web Design Company in Bangalore
Website development in Bangalore

Anonymous said...

Simple and easy to understand. Thank you, Sunil.

cenforce 200mg said...

Erection is a side effect of an ordinary, solid body, from which it is realized that the blood is streaming in the very perfect heading. As you age, you will see that the erection is diminishing consistently. At that age, you need to depend on medications like vidalista 60 , and fildena 150 prior to engaging in sexual relationships, and just you want to counsel a specialist prior to settling on any choice.

cenforce 200 is the tablet to Treat Erectile Dysfunction, Control, and Maintain an Erection. containing sildenafil citrate as the principle fixing in measurements of cenforce 100 .