Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Misc

jsp page cache

 

 

Varnish misc RSS feed   Index | Next | Previous | View Threaded


jewel.nuruddin at eastbeam

Feb 7, 2012, 9:37 PM

Post #1 of 4 (152 views)
Permalink
jsp page cache

Hello,
My varnish could not cache .jsp page.
Can any body help me how can I cache .jsp page?
Thanks
Jewel


savetheinternet at tinyboard

Feb 7, 2012, 9:47 PM

Post #2 of 4 (123 views)
Permalink
Re: jsp page cache [In reply to]

Hi,

The file extension should be irrelevant unless you specify otherwise.
You should take a read of some of the VCL examples here:
https://www.varnish-cache.org/trac/wiki/VCLExamples.

Below is wholly untested sample code for explicitly caching .jsp files
for 1 hour.

--

sub vcl_recv {
# match .jsp files
if(req.url ~ "\.jsp$") {
return (lookup);
}
# [...]
}

sub vc_fetch {
if(req.url ~ "\.jsp$") {
# set ttl for one hour
set beresp.ttl = 1h;
}
# [...]
return (deliver);
}

--

Thanks,
Michael

On Wed, Feb 8, 2012 at 4:37 PM, Jewel Nuruddin
<jewel.nuruddin [at] eastbeam> wrote:
> Hello,
> My varnish could not cache .jsp page.
> Can any body help me how can I cache .jsp page?
> Thanks
> Jewel
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


bjorn at ruberg

Feb 7, 2012, 10:55 PM

Post #3 of 4 (151 views)
Permalink
Re: jsp page cache [In reply to]

On 02/08/2012 06:37 AM, Jewel Nuruddin wrote:
> Hello,
> My varnish could not cache .jsp page.
> Can any body help me how can I cache .jsp page?

You must make sure your JSP page allows Varnish to cache it, and/or
force caching in Varnish.

Keep in mind that cookie and set-cookie headers will usually make
Varnish not cache anything. If this is the case with your setup,
https://www.varnish-cache.org/trac/wiki/VCLExampleCacheCookies might be
helpful.

If you want a better response, you should show a varnishlog extract
where the .jsp page is not being cached (so we can see exactly *why*
it's not cached), and also your current VCL.

--
Bjørn


_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


bjorn at ruberg

Feb 8, 2012, 12:05 AM

Post #4 of 4 (140 views)
Permalink
Re: jsp page cache [In reply to]

Please reply to the list. Please do not top post.

On 08. feb. 2012 08:45, Jewel Nuruddin wrote:
> Hi
> I use force caching in varnish like below
> sub vcl_recv {
>
>
> if (req.http.pragma ~ "no-cache" || req.http.Cache-Control ~
> "no-cache") {
> return (lookup);
> }
>
> unset req.http.cookie;
> return (lookup);
>
> if (req.request == "GET" || req.request == "HEAD") {
> if (req.url ~
> "\.(png|gif|jpg|swf|css|js|jsp|html|htm)$") {
> return (lookup);
> }
> }
>
> # set req.backend = web;
> # if ( (req.request == "GET") && (req.url ~ "\.jsp") ) {
> # return(lookup);
> # }
>
> set req.backend = web;
> }
>
> But it can not cache .jsp file ?
>
> What I did mistake?

You are not considering set-cookie from the backend. This would be done
in vcl_fetch, as detailed in the URL I referred to in my previous response.

Also, as mentioned, please include a varnishlog extract.

--
Bjørn


_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Varnish misc RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.