You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ch...@labware.com on 2012/06/27 09:16:59 UTC

how to configure Tomcat for leveraging browser caching?

Hi , 
     I ran Google's Page Speed(
https://developers.google.com/speed/pagespeed/ ) on our web app to analyze 
and optimize our web site .

One of the many items under Web Performance Best Practices (
https://developers.google.com/speed/docs/best-practices/caching#LeverageBrowserCaching 
) as listed in Page Speed says "To take advantage of the full benefits of 
caching consistently across all browsers, we recommend that you configure 
your web server to explicitly set caching headers and apply them to all 
cacheable static resources, not just a small subset (such as images). 
Cacheable resources include JS and CSS files, image files, and other 
binary object files (media files, PDFs, Flash files, etc.). In general, 
HTML is not static, and shouldn't be considered cacheable."
How do I configure tomcat to achieve the same ? I know it can be done via 
Filters by putting some HTTP headers but can we do it without touching 
code just by configuration ?

Regards,

Subhrajyoti 
Mobile: +919830079545
Mail: choudhury@labware.com
Web: www.labware.com

LabWare LIMS Solutions - Results Count

Re: how to configure Tomcat for leveraging browser caching?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Subhrajyoti,

On 6/27/12 3:16 AM, Choudhury@labware.com wrote:
> Hi , I ran Google's Page Speed( 
> https://developers.google.com/speed/pagespeed/ ) on our web app to
> analyze and optimize our web site .
> 
> One of the many items under Web Performance Best Practices ( 
> https://developers.google.com/speed/docs/best-practices/caching#LeverageBrowserCaching
>  ) as listed in Page Speed says "To take advantage of the full
> benefits of caching consistently across all browsers, we recommend
> that you configure your web server to explicitly set caching
> headers and apply them to all cacheable static resources, not just
> a small subset (such as images). Cacheable resources include JS and
> CSS files, image files, and other binary object files (media files,
> PDFs, Flash files, etc.). In general, HTML is not static, and
> shouldn't be considered cacheable." How do I configure tomcat to
> achieve the same ? I know it can be done via Filters by putting
> some HTTP headers but can we do it without touching code just by
> configuration ?

It looks like you can use urlrewrite [1] with a <set> configuration to
set headers for specific URL patterns. So, technically, you need code
to do it, but you can use existing code instead of writing your own.
url-rewrite might be a bit heavy for your needs, and you may decide to
write your own simple filter.

- -chris

[1] http://www.tuckey.org/urlrewrite/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/rIgUACgkQ9CaO5/Lv0PDSSwCcCn69rXiHBI3RJtjXWDbrfni+
gcQAn13BawxoC5RzD4Ot7tJBVX4ZNqnR
=/w3Y
-----END PGP SIGNATURE-----

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