• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Cache Static content (js/css) in Tomcat 8

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
Sorry, if my question is a beginnary question. I'm a newbie in Tomcat.
I have a static page which loads large js/css files. How can i tell Tomcat to add expires header when serving them to browser? I' looking for something similar to .htaccess mechanism in Tomcat.

(I use Tomcat, because in my html pages i make some request to a Java-based application- which has already been added to Tomcat. But that's totally a separate application from my webpages.)

Thanks in advance for your help
 
Bartender
Posts: 20938
127
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Al!

I believe the primary way you do client-side cache control in Tomcat is by coding it on a per-file basis for the static content. For example, using META tags.

There is a "gotcha", though. When Tomcat is doing secured transfers (SSL/TLS), it will override the caching tags on the outgoing response stream for security reasons. The reason for that is that they assume that if it's sensitive enough to transfer encrypted, it's sensitive enough that you don't want to be keeping a copy on the client, where the copy can possibly be hacked. Or an exploit can leak in from before the SSL switch occurred.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!