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

本文介绍了Apache服务器中关于缓存设置的具体配置方法,包括如何为不同类型的文件设置缓存过期时间,以及如何通过重写规则将特定请求转发到其他服务器。此外还涉及了如何在HTML和JSP中禁用浏览器缓存。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值