Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Google Chrome + GET 304 Not Modified
Google Chrome + GET 304 Not Modified [message #756780] Mon, 14 November 2011 23:50 Go to next message
Andrew  is currently offline Andrew
Messages: 43
Registered: December 2009
Member
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 #757899 is a reply to message #756780] Thu, 17 November 2011 05:52 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger Herrmann
Messages: 335
Registered: July 2009
Senior Member
Andrew,

are you sure that this is an unwanted behavior in Chrome?
Anyhow, it seems to be a Chrome issue, or do other browsers show the
same behavior?
Did you ask on the Chrome forum/bug tracker if this is a known issue?

Regards,
Rüdiger

On 15.11.2011 05:50, Andrew wrote:
> 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 #758137 is a reply to message #757899] Mon, 21 November 2011 22:55 Go to previous messageGo to next message
Andrew  is currently offline Andrew
Messages: 43
Registered: December 2009
Member
Thx for you reply. This seems to be a Chrome issue only (tested on latest FF, Opera, IE8), but I didn't ask on the Chrome forum about it yet.
Maybe someone has a similar problem with Chrome ? Flickering image behavior in viewers are really annoying Sad
Re: Google Chrome + GET 304 Not Modified [message #758403 is a reply to message #758137] Wed, 23 November 2011 02:05 Go to previous messageGo to next message
Felix Yu is currently offline Felix Yu
Messages: 2
Registered: November 2011
Junior Member
Yes. This is a weird behavior from Chrome. Even if resources (js, css, img) are cached, Chrome still issue if-modified-since GET request to server. Only when 304 not modified response is received will Chrome look into the local cache. It seems like it is a bug in the latest Chrome release that has not yet been fixed.

I managed to figure out a workaround. For the particular resources that the if-modified since GET request is targeted (in your case the caching images), in the response header, set Pragma and cache-control fields to 'max-age=10000'. The way to change it depends on the web framework you are using. The annoying GET request will be gone and Chrome will look into the cache for the images.

Regards,

Felix
Re: Google Chrome + GET 304 Not Modified [message #758404 is a reply to message #758137] Wed, 23 November 2011 02:05 Go to previous messageGo to next message
Felix Yu is currently offline Felix Yu
Messages: 2
Registered: November 2011
Junior Member
Yes. This is a weird behavior from Chrome. Even if resources (js, css, img) are cached, Chrome still issue if-modified-since GET request to server. Only when 304 not modified response is received will Chrome look into the local cache. It seems like it is a bug in the latest Chrome release that has not yet been fixed.

I managed to figure out a workaround. For the particular resources that the if-modified since GET request is targeted (in your case the caching images), in the response header, set Pragma and cache-control fields to 'max-age=10000'. The way to change it depends on the web framework you are using. The annoying GET request will be gone and Chrome will look into the cache for the images.

Regards,

Felix
Re: Google Chrome + GET 304 Not Modified [message #1138835 is a reply to message #756780] Tue, 15 October 2013 07:04 Go to previous messageGo to next message
Nedelcho Delchev is currently offline Nedelcho Delchev
Messages: 6
Registered: May 2013
Junior Member
Hi,

Is it possible to fix this issue somehow at RAP framework at all? Many of our users using Chrome and the overall perception of RAP in general suffers, because of this annoying bug - no matter who is guilty.

Regards,
Nedelcho
Re: Google Chrome + GET 304 Not Modified [message #1153301 is a reply to message #1138835] Thu, 24 October 2013 10:14 Go to previous message
Nedelcho Delchev is currently offline Nedelcho Delchev
Messages: 6
Registered: May 2013
Junior Member
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
Previous Topic:How to attach the context menu to a custom widget
Next Topic:What to do about Eclipse RAP compatibility with Remote System Explorer?
Goto Forum:
  


Current Time: Fri Aug 22 17:39:05 EDT 2014

Powered by FUDForum. Page generated in 0.01861 seconds