Javascript 如何缓存png、ico、jpeg
如何使用htaccess在我的网站上缓存图像2天,以便:Javascript 如何缓存png、ico、jpeg,javascript,.htaccess,png,jpeg,ico,Javascript,.htaccess,Png,Jpeg,Ico,如何使用htaccess在我的网站上缓存图像2天,以便: 1 x 60 x 60 x 24 x 2 = 172800s 所以我想缓存“png,jpeg,jpg,ico,js”。如何使用htaccess执行此操作?您可以使用mod_expires模块(基于文件的MIME类型): 最后一个选项为您提供了更多选项,如强制无缓存等。我想您应该使用Apache标记,而不是Javascript。此外,这似乎对您不利:“如果您可以访问httpd主服务器配置文件,则应完全避免使用.htaccess文件”--
1 x 60 x 60 x 24 x 2 = 172800s
所以我想缓存“png,jpeg,jpg,ico,js”。如何使用htaccess执行此操作?您可以使用
mod_expires
模块(基于文件的MIME类型):
最后一个选项为您提供了更多选项,如强制无缓存等。我想您应该使用
Apache
标记,而不是Javascript
。此外,这似乎对您不利:“如果您可以访问httpd主服务器配置文件,则应完全避免使用.htaccess文件”--
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault A300
# png, jpeg, jpg, ico, js expire after 2 days
ExpiresByType image/gif A172800
ExpiresByType image/png A172800
ExpiresByType image/jpg A172800
ExpiresByType image/x-icon A172800
ExpiresByType application/x-javascript A172800
</ifModule>
<ifModule mod_headers.c>
ExpiresActive On
# png, jpeg, jpg, ico, js expire after 2 days
<filesMatch ".(gif|png|jpg|jpeg|ico|js)$">
Header set Cache-Control "max-age=172800"
</filesMatch>
</ifModule>