singlesite.blogg.se

Adding public private cache header
Adding public private cache header






adding public private cache header adding public private cache header

However, NGINX allows for a few more custom values: When setting the max-age, it's always done in seconds. However, for static resources like images, they may never change, and you should be fine setting high TTL values, even as high as two years. Setting a max age around a few minutes for your home page is long enough to cover immediate reloads, and quick enough to allow for swift propagation of updates. You don't want to cache your home page for a whole year, because you might be changing something on Tuesday. The trade-off here is between a long caching time and quick updates. TTL controls how long the object will stay in cache before being invalidated, prompting the user to request a new object. You'll also want to make sure you're setting reasonable Time-To-Live (TTL) values for each resource. Static resources, like CSS and images, can usually be cached, often for much longer. As a general rule, if the page is going to be the exact same for all users, like your home page, you can cache it. You can still cache these kinds of pages on the browser side alone (by setting Cache-Control to private Anything that requires a user to sign in should not be cached by a CDN, or else you will risk displaying one user's personal information to others. There are a few things to note though before you go adding it site-wide.Ĭertain pages should never be cached. Using it, you can specify which resources get cached, and for how long. If you'd like to learn more about CDNs, you can read our guide on them here.Ĭache-Control is a header that you can configure your web server to add to all outgoing requests. This improves access latency, performance, and greatly reduces the stress on your web server. The CDN sits in front of your web server and caches your pages on the server side, usually on multiple edge servers located around the world. However, many large sites will also make use of a Content Delivery Network, or CDN. The user's browser is a client-side cache. The next time they connect, if the object they're requesting is still in the cache, it will load from memory rather than asking for it again, speeding up performance significantly and reducing the load on your web server in the process. Every user's browser has a built-in cache, which stores static objects downloaded from websites.








Adding public private cache header