Google Chrome + GET 304 Not Modified [message #756780] |
Mon, 14 November 2011 23:50  |
Eclipse User |
|
|
|
Hi,
I'm using latest Google Chrome 15.0.874.120 (Linux, Windows) and I've got a problem with caching images (flickering behavior in network). It seems that this problem appears in the latest Chrome.
Steps to reproduce:
1. Using latest night rap build launch Workbench demo in Google chrome
2. Select view with tree and move mouse over items
In Developer Tools you can see GET request with status 304 Not Modified after each mouse over. Sometimes (not always) after page reloading cache start work fine and there is no additional requests for image.
|
|
|
|
|
|
|
|
Re: Google Chrome + GET 304 Not Modified [message #1153301 is a reply to message #1138835] |
Thu, 24 October 2013 10:14  |
Eclipse User |
|
|
|
Hi again,
As Felix suggested, here is some simple Filter, which can do the job:
...
public class ExpiresFilter implements Filter {
private static final String CACHE_CONTROL = "Cache-control"; //$NON-NLS-1$
private static final String MAX_AGE_10000 = "max-age=10000"; //$NON-NLS-1$
private static final String PRAGMA = "Pragma"; //$NON-NLS-1$
private static final String EXPIRES = "Expires"; //$NON-NLS-1$
private static final String RWT_RESOURCES_THEMES_IMAGES = "rwt-resources/themes/images/"; //$NON-NLS-1$
private static final String RWT_RESOURCES_GENERATED = "rwt-resources/generated"; //$NON-NLS-1$
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
chain.doFilter(request, response);
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
if (req.getRequestURL() != null
&& (req.getRequestURL().indexOf(RWT_RESOURCES_GENERATED) >= 0
|| req.getRequestURL().indexOf(RWT_RESOURCES_THEMES_IMAGES) >= 0)) {
res.setDateHeader(EXPIRES, (new GregorianCalendar(3000, 1, 1)).getTime().getTime());
res.setHeader(PRAGMA, MAX_AGE_10000);
res.setHeader(CACHE_CONTROL, MAX_AGE_10000);
}
}
@Override
public void destroy() {
}
...
and in web.xml add:
...
<filter>
<filter-name>ExpiresFilter</filter-name>
<filter-class><your package>.ExpiresFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
This is valid in case you are using the WAR packaged RAP application.
Regards,
Nedelcho
|
|
|
Powered by
FUDForum. Page generated in 0.34600 seconds