| 3052 |
vikas |
1 |
package in.shop2020.serving.interceptors;
|
|
|
2 |
|
|
|
3 |
import java.util.Date;
|
|
|
4 |
|
|
|
5 |
import javax.servlet.http.HttpServletResponse;
|
|
|
6 |
|
|
|
7 |
import org.apache.struts2.ServletActionContext;
|
|
|
8 |
|
|
|
9 |
import com.opensymphony.xwork2.ActionInvocation;
|
|
|
10 |
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
|
|
11 |
|
|
|
12 |
public class CachingInterceptor extends AbstractInterceptor {
|
|
|
13 |
private static final long serialVersionUID = -2714402286574091187L;
|
|
|
14 |
private static final long SECONDS_IN_HOUR = 60*60;
|
|
|
15 |
|
|
|
16 |
public String intercept(ActionInvocation actionInvocation) throws Exception {
|
|
|
17 |
HttpServletResponse response = ServletActionContext.getResponse();
|
|
|
18 |
long expiresTime = (new Date()).getTime() + SECONDS_IN_HOUR * 1000;
|
|
|
19 |
response.setDateHeader("Expires", expiresTime);
|
| 3056 |
vikas |
20 |
response.setHeader("Cache-Control", "private");
|
|
|
21 |
response.setHeader("Pragma", "");
|
| 3052 |
vikas |
22 |
return actionInvocation.invoke();
|
|
|
23 |
}
|
|
|
24 |
}
|