Use browser cache
Official words:
Browser caching of static assets can save users time if they will visit your site multiple times.
Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images).
Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.).
Typically, HTML is not a static resource and should not be considered cacheable by default. You should consider which caching policies apply to your site's HTML.
It is recommended to enable browser caching for your server. Static resources should have a cache validity period of at least one week.
Third-party resources such as ads or widgets should also have a cache lifespan of at least one day.
For all cacheable resources, we recommend the following settings:
Set Expires to a date in the future, at least one week and at most one year (we prefer to set Expires rather than Cache-Control: max-age because the former is more widely supported).
Benefits
This means that when someone visits your website, their mobile phone or computer browser will automatically and temporarily cache the js, css and images required by your website into the mobile phone or computer. In this way, when you visit the website again, you will not need to request these css and js files from the server again. In this way, your website will be much faster.
nginx configuration --expires
In the pagoda, put the following code in the pseudo-static rule
expires plays a role in controlling page caching. Reasonable configuration of expires can reduce many server requests. To configure expires, you can add it in the http segment, server segment or location segment.
``php
location ~ .(gif|jpg|jpeg|png|bmp|ico)$ {
root /var/www/img/;
expires 30d;
}``
Control the expiration time of pictures, etc. to 30 days. Of course, this time can be set longer. It depends on the situation
For example
location ~ \.(wma|wmv|asf|mp3|mmf|zip|rar|swf|flv)$ {
root /var/www/upload/;
expires max;
}