Subversion Repositories SmartDukaan

Rev

Rev 3052 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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);
3055 vikas 20
        response.setHeader("Cache-Control", "public");
3052 vikas 21
        return actionInvocation.invoke();
22
    }
23
}