Browsing caching lets you tell a visitor’s browser to store static assets on a visitor’s local computer. For subsequent visits, the visitor’s browser will load those files from the local cache, rather than your server, which speeds up load times.
To control browser caching behavior, you can use two tactics:
- Expires headers
These let you tell visitors’ browsers how long to store certain types of files in the browser cache. For example, “store PNG images for 30 days before re-downloading them”.
Both achieve the same effect, but cache-control is the newer and more flexible option. You can use both – just make sure the storage lengths match.
There are two ways to add cache-control or expires headers:
Many WordPress performance plugins already include features to implement browser caching for you including WP Rocket. Or, you could use the standalone Add Expires Headers plugin.
If you feel comfortable working with code, you can also set this up by editing your site’s .htaccess file (if using Apache) or Nginx config file (if using Nginx).
Here are the code snippets that you’ll need:
Apache cache-control (.htaccess):
Keep reading the article at Elementor Blog. The article was originally written by Sergei Davidov on 2021-03-02 07:45:29.
The article was hand-picked and curated for you by the Editorial Team of WP Archives.
This article was written by Sergei Davidov and originally published on Elementor Blog.