mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-09-20 15:35:55 +08:00
页面缓存是否启用可配置
This commit is contained in:
parent
c8ca1518d1
commit
47592dcde1
|
@ -48,11 +48,23 @@ public class RequestWatchHandler extends HandlerInterceptorAdapter {
|
|||
|
||||
private static final Log LOG = LogFactory.getLog(RequestWatchHandler.class);
|
||||
|
||||
// 设置页面无缓存
|
||||
// 如果使用了第三方缓存策略(如 nginx 的 etag),可以将此值设为 false
|
||||
private boolean noCache = true;
|
||||
|
||||
public void setNoCache(boolean noCache) {
|
||||
this.noCache = noCache;
|
||||
}
|
||||
|
||||
public boolean isNoCache() {
|
||||
return noCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler) throws Exception {
|
||||
response.setCharacterEncoding("utf-8");
|
||||
if (!ServletUtils.isAjaxRequest(request)) {
|
||||
if (noCache && !ServletUtils.isAjaxRequest(request)) {
|
||||
ServletUtils.setNoCacheHeaders(response);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
<mvc:interceptors>
|
||||
<mvc:interceptor>
|
||||
<mvc:mapping path="/**" />
|
||||
<bean class="com.rebuild.web.RequestWatchHandler"></bean>
|
||||
<bean class="com.rebuild.web.RequestWatchHandler">
|
||||
<property name="noCache" value="true" />
|
||||
</bean>
|
||||
</mvc:interceptor>
|
||||
</mvc:interceptors>
|
||||
|
||||
|
|
Loading…
Reference in a new issue