现在的位置: 首页 > 综合 > 正文

apache ,html,jsp 避免页面中的部分资源被cache

2013年03月01日 ⁄ 综合 ⁄ 共 1065字 ⁄ 字号 评论关闭

apache 中:
<VirtualHost 10.11.12.47>
    DocumentRoot /usr/local/resin/htdocs/
    ServerName www.test.com
    DirectoryIndex index.html index.jsp
    CustomLog logs/info/access_log combined
    ErrorLog logs/ding/error_log

    ExpiresActive on
    ExpiresByType image/gif A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType image/jpg A31536000
    ExpiresByType text/css A31536000
    ExpiresByType application/x-javascript A31536000

    <Location /script>
       <IfModule mod_expires.c>
        FileETag None
        ExpiresActive on
        ExpiresByType application/x-javascript A0
       </IfModule>
    </Location>

    <IfModule mod_rewrite.c>
    RewriteEngine on
        RewriteRule  ^/sf/.*/.js$       http://192.168.12.123:8080%{REQUEST_URI} [P]
    </IfModule>

html中:
<meta http-equiv=Pragma content=no-cache>

<meta http-equiv=expires content=0>

<meta http-equiv="cache-control" content="no-store">

jsp中:

response.setHeader( "Pragma", "no-cache" );
response.addHeader( "Cache-Control", "must-revalidate" );
response.addHeader( "Cache-Control", "no-cache" );
response.addHeader( "Cache-Control", "no-store" );
response.setDateHeader("Expires", 0);

抱歉!评论已关闭.