

Every other user will receive a cached copy.
#Private cache control header code#
Please feel free to explore the source code on GitHub and run the application locally. To test the different cache-control headers, I have created a repository containing a simple NodeJS server. no-store - Should not be stored on any cache.private - The response is intended for a single user and should only be stored by the browser cache.public - Any cache may store the response, including a CDN.The cacheability of a resource is set using the directives below: Browser cache is referred to as a private cache, while a CDN cache is referred to as a shared cache.

In addition to caching in your browser, if your content is behind a CDN then your cache-control headers influence how the CDN caches your content on the edge. Note: The Expires header is no longer needed as its behavior is covered by the Cache-Control header. In websites, this is dictated by the Cache-Control header which is defined in the HTTP/1.1 specification. This could be done to avoid having to recalculate an expensive computation or to place the content closer to the user.

My goal is to provide you with a reference which you could use to answer the question, “How should I cache this resource?” What is caching?Ī cache is a store where you could put a resource. Disclaimer: The scope of this article isn’t to serve as a comprehensive guide to all possible caching strategies and how they work - there’s already plenty of content like that around. “There are only two hard things in Computer Science: cache invalidation and naming things.” ( Phil Karlton)Ģ5 years later, this well-known saying still holds true and while I cannot help you with the naming, I want to share what I know about caching to make it easier for you to decide on a caching strategy.

Getting your caching strategy right can make a huge difference to your users - both repeat and first time. What’s quicker than a fast request? No request. Our relevante sections in web.Caching plays a fundamental role in performance. However, when a user is logged in to Episerver cache-control:private is send in the response instead.Īs we are using authentication for our end-users (we are provinding an extranet), it does not make any sense for us not to cache static content for those users.Īnyone who knows why cache-control: private is used by Episerver when a user is authenticated? We have setup caching for static content as described in, and it works fine for anonymous users.
