dtkl55257 2013-11-13 08:58
浏览 53

杠杆浏览器缓存无效

The browser caching is not working as my Apache mod_expires is enabled. I have checked this through phpinfo() under Loaded Modules

Below is my code in htaccess

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 seconds"
    ExpiresByType image/x-icon "access plus 2592000 seconds"
    ExpiresByType image/jpeg "access plus 2592000 seconds"
    ExpiresByType image/png "access plus 2592000 seconds"
    ExpiresByType image/gif "access plus 2592000 seconds"
    ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
    ExpiresByType text/css "access plus 604800 seconds"
    ExpiresByType text/javascript "access plus 216000 seconds"
    ExpiresByType application/x-javascript "access plus 216000 seconds"
    ExpiresByType text/html "access plus 600 seconds"
    ExpiresByType application/xhtml+xml "access plus 600 seconds"
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\\.(ico|jpe?g|png|gif|swf)$">
        Header set Cache-Control "max-age=2692000, public"
    </FilesMatch>
    <FilesMatch "\\.(css)$">
        Header set Cache-Control "max-age=2692000, public"
    </FilesMatch>
    <FilesMatch "\\.(js)$">
        Header set Cache-Control "max-age=2692000, private"
    </FilesMatch>
    <FilesMatch "\\.(x?html?|php)$">
        Header set Cache-Control "max-age=600, private, must-revalidate"
    </FilesMatch>
    Header unset ETag
    Header unset Last-Modified
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(bmp|css|flv|gif|ico|jpg|jpeg|JPG|js|pdf|png|svg|swf|tif|tiff)$">
        Header set Last-Modified "Mon, 27 Aug 2012 00:00:00 GMT"
    </FilesMatch>
</IfModule>
  • 写回答

1条回答 默认 最新

  • douyihuaimao733955 2016-05-30 19:56
    关注

    check if this code works

    <IfModule mod_headers.c>
    <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|swf|woff)$">
      Header set Cache-Control "max-age=2678400, public"
    </filesmatch>
    <filesmatch "\.(html|htm)$">
      Header set Cache-Control "max-age=7200, private, must-revalidate"
    </filesmatch>
    <filesmatch "\.(pdf)$">
      Header set Cache-Control "max-age=86400, public"
    </filesmatch>
    <filesmatch "\.(js|css)$">
      Header set Cache-Control "max-age=604800, private"
    </filesmatch>
    

    评论

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式