For picture websites, pictures must be re-downloaded every time the page is opened, which is not only slow, but also a waste of traffic. At this time, you need to use caching to force the browser to cache image files
Cache files, ask how many times the website has been visited, and reduce traffic consumption. 2 caching codes are now provided
Open the .htaccess file and write the following code
Method 1: Unify cache duration
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|txt|swf|pdf|swf|js)$"> Header set Cache-Control "max-age=2592000" </FilesMatch>
Method 2: Cache duration according to different file types
<IfModule mod_expires.c> 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 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" #默认文件缓存时长,慎用 </IfModule>
Note:
ExpiresDefault "access 1 month", the default file cache duration, use with caution, otherwise some of your methods will be invalid, such as recording page views, you must refresh the page with F5
Extended reading:
How to create .htaccess file?
Download .htaccess file
Original address: http://cssteach.com/show-20-113.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6
Visual web development tools