首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nginx‘干扰’缓存响应?

问nginx‘干扰’缓存响应?
EN

Stack Overflow用户
提问于 2016-02-05 20:06:32
回答 1查看 138关注 0票数 0

我在Tomcat 7中运行了一个Spring应用程序,在Tomcat前面有nginx1.1.19。

我在Security中启用了Cache-Control:max-age=31536000, must-revalidate,并且报头很好地返回到浏览器。

如果我直接将应用程序运行到Tomcat --一切都像预期的那样工作,静态资源都会返回304。

在nginx中运行--一些静态资源返回304,有些返回200,所有这些都显示格式正确的Cache-Control头。在缓存的内容中,我找不到任何模式。

nginx吐露非常简单:

代码语言:javascript
复制
location /TSAdmin {
         proxy_pass http://localhost:8030;
         proxy_redirect http://localhost:8030 https://10.10.5.63;
 }

任何想法都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-17 03:54:20

这是一个问题,这两个片段解决了这个问题:

代码语言:javascript
复制
   <http>
      <headers>
         <cache-control disabled="true" />
      </headers>
      <intercept-url pattern="/css/**" access="permitAll" />
      <intercept-url pattern="/frameworks/**" access="permitAll" />
      <intercept-url pattern="/img/**" access="permitAll" />
      <intercept-url pattern="/js/**" access="permitAll" />
      <intercept-url pattern="/fonts/**" access="permitAll" />
      <intercept-url pattern="/images/**" access="permitAll" />
   </http>

和

代码语言:javascript
复制
   <mvc:resources location="/, /css/" mapping="/css/**" cache-period="31536000" />
   <mvc:resources location="/, /frameworks/" mapping="/frameworks/**" cache-period="31536000" />
   <mvc:resources location="/, /img/" mapping="/img/**" cache-period="31536000" />
   <mvc:resources location="/, /js/" mapping="/js/**" cache-period="31536000" />
   <mvc:resources location="/, /fonts/" mapping="/fonts/**" cache-period="31536000" />
   <mvc:resources location="/, /images/" mapping="/images/**" cache-period="31536000" />

为我们解决了一些问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35232614

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档