users@jersey.java.net

[Jersey] Firefox making multiple GET requests against a resource - any idea why?

From: Alex Bleasdale <rhodlite78_at_yahoo.co.uk>
Date: Thu, 12 Nov 2009 08:41:50 -0800 (PST)

Hi,

I'm wondering if anyone else is experiencing a similar issue -

I've created a resource that returns a 1x1 transparent gif image called
ONE_BY_ONE (the response is written out from a static byte array containing
the necessary information).

At the top of the method, I'm using the @Produces annotation to set the mime
type to "image/gif" and - for each get request - the resource uses hibernate
to write out one row to a table.

On completion, the final response is rendered like so in my resource method:

return Response.ok(ONE_BY_ONE).cacheControl(cc).type("image/gif").build();

I've tested the resource in Firefox, Opera, Chrome and IE8 (all patched and
up-to-date) in Windows XP.

On making a request to "get" the resource, Opera, Chrome and IE8 all
register one request, which in turn writes out one row. This is the desired
behaviour and is consistent even over several attempts.

However, getting the resource using Firefox (3.5) will cause 2 (and
sometimes 3) rows to be written every time. In other words, from looking at
the logs, it would appear that the "GET" happens multiple times.

The only info I've managed to find online regarding how I may be able to go
about solving this this is:
http://forums.mozillazine.org/viewtopic.php?f=25&t=1412535

Their suggestion of adding character encoding was something I tried
(@Produces("image/gif;charset=ISO-8859-1")) but this has not appeared to
make any difference whatsoever.

From looking at the response in Firebug, the content-encoding has been set
to gzip and I was wondering whether this would be incorrect for a gif
(output from a byte[])?

I've seen in some places, a recommendation for Content-Transfer-Encoding:
base64 when "producing" gifs and was wondering whether I should set this
(and indeed, whether it would make any difference if I did).

Firstly, does anyone know how to alter the transfer encoding and is it
something that should be done if you're using jersey to output images (and
the like).

Secondly, has anyone else found themselves to be in a similar situation with
Firefox? If so, can they offer me any advice as to what my options are?

Thanks in advance,
A
-- 
View this message in context: http://n2.nabble.com/Firefox-making-multiple-GET-requests-against-a-resource-any-idea-why-tp3994046p3994046.html
Sent from the Jersey mailing list archive at Nabble.com.