participate


Sun Java Studio Creator - Creator an cache
<<   Back to Forum  |   Give us Feedback
This topic has 7 replies on 1 page.
walid.k
Posts:91
Registered: 1/12/06
Creator an cache   
Feb 21, 2006 3:47 AM

 
Hi,

in source of page generated by creator, there's some meta tags about cache
<meta content="no-cache" http-equiv="Pragma" />
<meta content="no-cache" http-equiv="Cache-Control" />
<meta content="no-store" http-equiv="Cache-Control" />
<meta content="max-age=0" http-equiv="Cache-Control" />
<meta content="1" http-equiv="Expires" />

why no-cache and how i can change this

i use firefox and in the cache i found urls like this:

testEmp/theme/com/sun/rave/web/ui/defaulttheme/images/table/lite_column_hdr_hov_gradient.jpg

/testProd3/theme/com/sun/rave/web/ui/defaulttheme/images/table/select_multiple.gif;jsessionid=8bb5fd719273aaffffffffee5814659e871ec

there's any way to have image url without jsessionid, because it's random and the cache fonctionality of browser not used in this case

testProd3/theme/com/sun/rave/web/ui/defaulttheme/javascript/table.js

java scripts like table.js have 54k or more.

if i have ten projects, it's not useful to have one theme per project, i want have shared theme to store creator images and scripts and my images scripts and css. with this method table.js will have same url for all the projects and browser caching is used correctly.

Thank you very much.

Walid
 
walid.k
Posts:91
Registered: 1/12/06
Re: Creator and cache   
Feb 23, 2006 3:42 AM (reply 1 of 7)  (In reply to original post )

 
Hi,

actually to create .js or .css files, we use resources folder in the project. In the future we aim have resource folder shared between projects and to deposit css,js and images commun run with all our projects, with this methode the maintenance of these files is simplified and browsers cache fonctionnality is optimized because these files will have the same url not an url per project.
defaults themes and scripts generated by creator will have the same shared resources folder, and its URL is independent of the project.

Thank you very much.

Walid.
 
jaguar2010
Posts:106
Registered: 5/11/05
Re: Creator and cache   
Mar 8, 2006 11:03 AM (reply 2 of 7)  (In reply to #1 )

 
I have the same issue, I want to modify/remove the meta tags on the header, that is automatically generated by Creator.

<head>
<meta content="no-cache" http-equiv="Pragma" />
<meta content="no-cache" http-equiv="Cache-Control" />
<meta content="no-store" http-equiv="Cache-Control" />
<meta content="max-age=0" http-equiv="Cache-Control" />
<meta content="1" http-equiv="Expires" />

How can I remove/modify them ?

Adding my own meta tags don't do the trick.
 
3431603
Posts:164
Registered: 8/25/98
Re: Creator and cache   
Mar 8, 2006 1:53 PM (reply 3 of 7)  (In reply to #2 )

 
The meta tags are emitted by the "Head" component, which does not currently have any options to turn them off . I filed RFE 6395821.

/krys
Creator Team
 
jaguar2010
Posts:106
Registered: 5/11/05
Re: Creator and cache   
Mar 8, 2006 6:45 PM (reply 4 of 7)  (In reply to #3 )

 
Thanks. However, for the short term fix do you know of any trick that would allow me to override these meta tags with my own ?

Thanks
Faraz
 
Schottkey
Posts:11
Registered: 6/5/06
Re: Creator and cache   
Jun 6, 2006 1:44 AM (reply 5 of 7)  (In reply to #4 )

 
I have the same issue with the back button. It's possible to turn of the above meta tags ??

Thanks and best regards,
Daniel
 
lowec
Posts:36
Registered: 5/27/05
Re: Creator and cache   
Jun 7, 2006 6:41 AM (reply 6 of 7)  (In reply to #4 )

 
Thanks. However, for the short term fix do you know
of any trick that would allow me to override these
meta tags with my own ?

Thanks
Faraz

I used a filter to set the parameters:

public class CacheControlFilter implements Filter {
  private Calendar calendar;
  private final DateFormat formatter;
  
  public CacheControlFilter() {
    calendar = new GregorianCalendar();
    
    formatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
    
    final Date date = calendar.getTime();
    
    final TimeZone tz = TimeZone.getTimeZone("GMT");
    
    formatter.setTimeZone(tz);
  }
 
  public void init(final FilterConfig filterConfig) throws ServletException { }
 
  public void doFilter(final ServletRequest req,
                       final ServletResponse res,
                       final FilterChain chain)
    throws IOException,
           ServletException
  {
    chain.doFilter(req, res);
 
    // compute cache expiry time to be 30 days from now.
    calendar.setTime(new Date());
    calendar.add(Calendar.DAY_OF_MONTH, 30);
    
    final String expires = formatter.format(calendar.getTime());
    
    ((HttpServletResponse) res).addHeader("Expires", expires);
    ((HttpServletResponse) res).addHeader("Cache-Control", "max-age=2592000");
  }
 
  public void destroy() { }
}


Then in web.xml, I configured the filter as follows:
  <filter>
    <filter-name>CacheControlFilter</filter-name>
    <filter-class>filter.CacheControlFilter</filter-class>
  </filter>
 
  <filter-mapping>
    <filter-name>CacheControlFilter</filter-name>
    <url-pattern>*.png</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>CacheControlFilter</filter-name>
    <url-pattern>*.css</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>CacheControlFilter</filter-name>
    <url-pattern>*.js</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>CacheControlFilter</filter-name>
    <url-pattern>*.gif</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>CacheControlFilter</filter-name>
    <url-pattern>*.jpg</url-pattern>
  </filter-mapping>


This cut down the number of requests to my server.
 
rafael.pereyra
Posts:1
Registered: 2/2/08
Re: Creator and cache   
Feb 2, 2008 12:17 PM (reply 7 of 7)  (In reply to #6 )

 
lowec,

I just wanted to thank you for this solution. I've posted a question regarding .js,.css and images files not being cached in internet explorer. Your post was very helpfull on cutting down the request on my server.

Just to add my two cents, I've changed your class a little by adding:



if (pResponse.containsHeader("Expires"))
    {
        pResponse.setHeader("Expires", expires);    
    }
    else
    {
        pResponse.addHeader("Expires", expires);    
    }
    
    if (pResponse.containsHeader("Cache-Control"))
    {
        pResponse.setHeader("Cache-Control", "public");                
    }
    else
    {
        pResponse.addHeader("Cache-Control", "public");        
    }


The idea is to avoid multiple Cache-Control tags on the response. Also I've moved the

chain.doFilter(req, res);


to the bottom of the method so I can use a another filter is necessary and override my response settings (but haven't tried yet ;)).

Thanks!

PS: My application is JSF using Woodstock components and developed on Netbeans 6.0. According to the documentation, the ThemeServlet should be filling the response header properly, however I've found that this is not true. In mos of the cases I get an expires date around 1969, and Cache-Control = No-Cache. Maybe a problem with my setup, but the filter is doing a great job anyway!
 
This topic has 7 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 27
  • Guests : 138

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums