You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Arjun Dhar <dh...@yahoo.com> on 2011/03/19 09:39:16 UTC

Caching Streamed Images on browser

Hi,
 I have a resource (an Image which exists on the File System outside the Web
Context).
I stream the image resource. The problem really is that while the speed to
download an image within web-context and outside is the same .... the one
within Web-Context is always cached by the browser.

Am not sure this is a pure wicket question, but anyone know the rules for
browser caching images? As long as the "src" link is the same and
independent of session why would the browser not cache it?

I also created a simple DownloadServlet and same result. URL -->
"/DownloadServlet?file=abc".


-----
Don't take life too seriously, your'e not getting out it alive anyway!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Streamed-Images-on-browser-tp3389269p3389269.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Streamed Images on browser

Posted by Arjun Dhar <dh...@yahoo.com>.
Got it!

As per ETag specs in Firefox Docs,:

The "Last-Modified" response header can be used as a weak validator.  It is
considered weak because it only has 1-second resolution. 
If the "Last-Modified" header is present in a response, then the client can
issue an "If-Modified-Since" request header to validate the cached document.

When a validation request is made, the server can either ignore the
validation request and response with a normal 200 OK, or it can return 304
Not Modified to instruct the browser to use its cached copy. 
The 304 response can also include headers that update the expiration time of
the cached document.


Setting 'Last-Modified' did the trick for me.

thanks

-----
Don't take life too seriously, your'e not getting out it alive anyway!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Streamed-Images-on-browser-tp3389269p3436099.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Streamed Images on browser

Posted by Arjun Dhar <dh...@yahoo.com>.
Hey, thanks for the response ... though i think there is more to it.
When I look at the header of a normal image in web context, he server
returns 302 (NO MODIFIED).

Despite me changing the HTTP cache controls, a "HTTP/1.1 200 OK" still makes
the browser stream the image from the server. Using HTTP live Headers i
ensured the HTTP headers match that of normal image Ditto. This (200 vs 302)
is the only noticeable difference. Am unable to force a 302 for some reason
(...am looking at that)


Any ideas?

Will some sort of UrlCodingStrategy to avoid params in my URL trick the
browser and tomcat server in thinking its a genuine image resource?
like : /my/synthetic/image/image1.jpg instead of Download?image=image1.jpg.

Any ideas?




-----
Don't take life too seriously, your'e not getting out it alive anyway!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Streamed-Images-on-browser-tp3389269p3436023.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Streamed Images on browser

Posted by Pedro Santos <pe...@gmail.com>.
Browser respect cache control headers of the HTTP response, u can set your
caching rules there.

On Sat, Mar 19, 2011 at 5:39 AM, Arjun Dhar <dh...@yahoo.com> wrote:

> Hi,
>  I have a resource (an Image which exists on the File System outside the
> Web
> Context).
> I stream the image resource. The problem really is that while the speed to
> download an image within web-context and outside is the same .... the one
> within Web-Context is always cached by the browser.
>
> Am not sure this is a pure wicket question, but anyone know the rules for
> browser caching images? As long as the "src" link is the same and
> independent of session why would the browser not cache it?
>
> I also created a simple DownloadServlet and same result. URL -->
> "/DownloadServlet?file=abc".
>
>
> -----
> Don't take life too seriously, your'e not getting out it alive anyway!
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Caching-Streamed-Images-on-browser-tp3389269p3389269.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos