• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat Apache mod_jk2 Caching Resource Files

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

With this configuration we have a servlet which basically retrieves the resource file like (image,css,xml files) many times from different URLs

Way:1 (using URLConnection )
=============================
URL siteURL = new URL(urlPath);
URLConnection siteConn = siteURL.openConnection();
siteConn.connect();
InputStreamReader isReader =new InputStreamReader(siteConn.getInputStream());

int i = -1;
StringBuffer respBuff = new StringBuffer();

while((i=isReader.read()) != -1) {
respBuff.append(String.valueOf((char)i));
}
ServletOutputStream sos = response.getOutputStream();
sos.write(sBuffer.toString().getBytes());

Way:2 (using URL )
==================
DataInputStream dis = new DataInputStream(url.openStream());
while ( dis.read(bytes) != -1) {
sos.write(bytes);
}

Problem:
=========
Actually the servlet is invoked many times for the same resources again and again. We want to avoid that and we want a way to configure a particular list of resource files(cache only which has extensions xml, gif etc) to be cached automatically by Apache.

Or other way is we can also pass an extra parameter along with the URL which decides whether this has to be cached or not. Like

http://192.165.121.101/folder/imgs/res1.xml?cache=true
this should be cached by Apache

http://192.165.121.101/folder/imgs/res2.xml?cache=false
this should not be cached by Apache

Any solution?

Thanks in Advance,
Govarthanan
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic