WordPress blog caches all images to the browser to improve loading speed

888u

Last update at :2023-12-31,Edit by888u

The WordPress program itself is relatively bloated. If there are a large number of images, the page loading speed will become slower. For some websites, some user resources may be lost. The following method can be used to solve this problem by caching images. When the page is loaded for the first time, all images are stored in the browser's cache pool. This can improve loading speed and achieve the purpose of website optimization.

Enabling browser caching means that the css and js files downloaded when the visitor visits for the first time are stored on the visitor's local computer. When the visitor visits the website for the second time, the browser does not need to download the css and js files and directly calls the local css and js files. js file to speed up the loading of web pages.

How to enable browser caching on Apache server

On the LAMP server, edit the .htaccess file in the root directory of the website and add the following content:

## EXPIRES CACHING ##

ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 days"

## EXPIRES CACHING ##

This basically caches most of the larger files.

How to enable browser caching on Nginx server

Edit the location section in the website's configuration file bo.moioi.com.conf to the following content:

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires 365d;
    }location ~* \.(pdf)$ {
        expires 30d;
}

Then restart the nginx service service nginx restart and you're done.
Enabling browser caching on your WordPress website can improve your Google Pagespeed Test score.

Note: The content is collected from the Internet, so please make a backup of the source file before modifying it to prevent losses caused by errors in modification!

Recommended site search: check ip, java virtual host, how to check ip, server rental US high defense, registration number query, bbs registration, Wanwang free domain name, domain name error correction system, overseas virtual host, ip proxy free version,

WordPress blog caches all images to the browser to improve loading speed

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码