---
title: "struts1的tiles导致的response cache无法禁止的issue"
author: "cuishen"
date: "2014-02-15T00:13:41Z"
tags: []
categories: ["企业架构"]
slug: "struts1-tiles-response-cache-issue"
draft: false
lastmod: "2014-02-15T20:40:24Z"
id: 2017537
url: "https://cuishen.iteye.com/blog/2017537"
---

近日struts 1项目中遇到一个很怪异的问题，项目中的所有.do都是继承自同一个root tiles，根JSP里面有把cache禁掉：

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

```

但是在firebug里面看http response，大部分.do的response都没有cache，但是有个别.do的response cache依旧存在。。。

真见鬼了。。。

后仔细比对struts-config，发现那两个特殊的.do，都是在tiles里面forward到了其他.do:

```xml

<action path="/Index" type="com.cuishen.HomeAction">
	<forward name="success" path="success.home"/>
</action>

```


```xml

<definition name="success.home" path="/user/info.do" />

```

上例中"/Index.do"和"/user/info.do"都是继承的相同的根JSP，但是访问"/Index.do"页面会被缓存，直接访问"/user/info.do"则不会！

后将"/Index.do"中的tiles移除，直接forward到"/user/info.do"，后问题解决（如下代码）！ （我擦，一般人还真想不到！！）

```xml

<action path="/Index" type="com.cuishen.HomeAction">
	<forward name="success" path="/user/info.do"/>
</action>

```