Use. htaccess to cache browser image files ,. Using. htaccess to cache browser image files. for image websites, you need to download images again every time you open the page. this is a waste of traffic. In this case, you need to use. htaccess to cache browser image files,
For image websites, you need to download images again every time you open the page. this is a waste of traffic. Cache is required to force the browser to cache image files.
Cache Files, question the number of website renewals, reduce traffic consumption, now provides the cache code in 2
Open the. htaccess file and write the following code:
Method 1: uniform cache duration
Header set Cache-Control "max-age=2592000"
Method 2: cache duration based on different file types
ExpiresActive OnExpiresByType 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 text/html "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 month" # default file cache duration, use with caution
Note:
ExpiresDefault "access 1 month", default file cache duration, use with caution, otherwise some of your methods will fail, such as record the page views, you must F5 refresh the page to be able
Additional reading:
How to create a. htaccess file?
Download the. htaccess file
Address: http://cssteach.com/show-20-113.html
For image websites, you need to download images again every time you open the page. this is a waste of traffic. In this case, you need to use the cache...