HTTP headers let clients or servers send additional information with those client requests and server responses. The browser would then repeat the same process for every resource on your site, including CSS stylesheets, JavaScript, etc. When a client needs a file, it sends a request to the server and the server sends a response to the client.įor example, if your website has an image, a visitor’s browser would first request that image from the server and then the server would respond with the image file. For our purposes, a client is a visitor’s web browser and a server is your WordPress site’s server. HTTP, short for Hypertext Transfer Protocol, governs how clients and servers communicate. More specifically, cache-control is an HTTP header, which brings us to another term that we need to define. For example, you can say that a visitor’s browser can cache a certain image, but a CDN (such as Cloudflare) cannot cache it. It gives you lots of control over how each individual resource behaves and it also lets you control who can cache your content. What Is Cache-Control, Then?Ĭache-control is one of the main methods to control this browser caching behavior, with the other being expires headers.īasically, cache-control lets you set these “expiration” dates to control whether a visitor’s browser will load a resource from its local cache or send a request to your site’s web server to download the resource. If you’re using WP Rocket, WP Rocket will automatically implement both page caching and browser caching for you – more on this later. Note – browser caching is a separate strategy from page caching, which is what most people are talking about when they reference “caching” for WordPress. By setting an expiration date, you’re ensuring that visitors will periodically re-download the relevant resources to ensure an updated experience.įor more, check out our full explanation post on browser caching. Why add expiration dates at all? Because you want to make sure your visitors still get the most recent version of your page. “Hey, store JPEG files for one year, but only store PNG files for one month”.īasically, you set up expiration dates for how long visitors’ browsers should store certain content. In order to enable browser caching, you need to configure your web server so that it tells visitors’ browsers which types of files to store and how long to store them for before re-downloading them.įor example, you can configure your server to say: This is why you typically see “Leverage browser caching” as a common recommendation in tools like GTmetrix and Pingdom. Then, a visitor’s browser can load that resource locally rather than re-downloading it, which will speed up your site’s load times and create a better experience for your visitors. Forcing a visitor’s browser to re-download your logo for every single page load is just a waste of resources that will slow down your site.īrowser caching lets you avoid that scenario by saving certain types of resources on a visitor’s local computer. However, on subsequent visits, it doesn’t make sense to force them to request and download every single resource on each visit.įor example, your logo probably loads on every single page, but it doesn’t change that often. When someone visits your website for the first time, their web browser needs to request and download every single file to render your page. How cache-control applies to WordPress/WP Rocket users.What cache-control is and how it works (HTTP headers).But before we get into the cache-control header, we first need to explain the concept of browser caching. In this article, we’ll explain what cache-control is and how it affects behavior on your website. That sounds a little complicated – we know! So if you bear with us, we’ll dig into the topic of cache-control in much greater detail. In a nutshell, cache-control is an HTTP header that specifies browser caching policies for certain static resources on your website, such as your images. Confused by what the cache-control HTTP header is and how it works with your WordPress site?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |