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:

  1. Practically and neatly explained. Thanks!

    ReplyDelete
  2. Thank you Sunil, It was really helpful.

    ReplyDelete
  3. Good and crispy explanation... Cheers buddy

    ReplyDelete
  4. images is not place in right description

    ReplyDelete
  5. good, it explained clearer than w3.

    ReplyDelete
  6. Awesome Explanation , Better than Wiki

    ReplyDelete
  7. Thanks Sunil. That clears my doubt on no cache.

    ReplyDelete
  8. Nice and Awesome...

    ReplyDelete
  9. Great Explanation! :)

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

    ReplyDelete
  11. Simple and easy to understand. Thank you, Sunil.

    ReplyDelete
  12. 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 .

    ReplyDelete