Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7856021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:33:46+00:00 2026-06-02T20:33:46+00:00

Glassfish 3.1.2, Mojarra 2.1.6, SSL activated I have an question about static resource caching.

  • 0

Glassfish 3.1.2, Mojarra 2.1.6, SSL activated

I have an question about static resource caching. I´ve read some posts about this but I´m not sure which options we should use. This

https://developers.google.com/speed/docs/best-practices/caching

is also an good article about resource caching. Within our application server SSL is activated. We see that static resources (images, scripts, css) are not cached.

Here is my test filter:

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;
        String uri = httpRequest.getRequestURI();
        if (GET_METHOD.equalsIgnoreCase(httpRequest.getMethod()) && uri.contains(ResourceHandler.RESOURCE_IDENTIFIER)) {
            httpResponse.setDateHeader("Expires", System.currentTimeMillis() + 2419200000L); // 1 month in future.
            httpResponse.setDateHeader("Last-Modified", System.currentTimeMillis() - 2419200000L); // 1 month in past.
            httpResponse.setHeader("Cache-Control", "public"); // Secure caching
        }
    }
    chain.doFilter(request, response);
}
  • Expires: Ok. It´s an static resource that doesn´t change, so we set the expiration date one month in the future.
  • Last Modified: Not sure. I´ve read that setting this to the past has also impaces on caching
  • Cache-Control: Ok. Allow secure caching. Security impacts?

Are there any impacts with this settings? I´ve also read a lot of posts where caching should be disabled through an filter. The only problem I see is that users could have a problem on a new release. Styles and Scripts could be changed in the new release but the browser ignore the new one and use the files from cache.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:33:48+00:00Added an answer on June 2, 2026 at 8:33 pm

    You only need to set Cache-Control. The Expires and Last-Modified are already set by default ResourceHandler (and would override the values set by your filter). The Last-Modified must represent the last modified timestamp of the resource in question. You can obtain it by servletContext.getResource(path).openConnection().getLastModified(). But you don’t need to set it here anyway. Just let ResourceHandler handle.

    As to versioning, just use resource libraries rightly. You can put a version folder matching regex pattern \d+(_\d+)* in the library folder and the ResourceHandler will serve the newest.

    E.g.

    /resources/libraryname/1_0/js/file.js
    /resources/libraryname/1_1/js/file.js
    /resources/libraryname/1_2/js/file.js
    

    The following will then get the one from 1_2:

    <h:outputScript library="libraryname" name="js/file.js" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain this phenomenon? I am using Mojarra 2.1.6 - Glassfish 3.1.2.
Question appears during porting application from JSF 1.2 to JSF 2.0.3 (Mojarra). I have
Hi I have read Glassfish 3.1.2's JDBCRealm has a new Password Encryption Algorithm field.
In my instance, I have Glassfish 3.1.1 / Mojarra 2.1.3 I could remove the
I have a problem with a JSF project. GlassFish Server 3.1.2 Mojarra 2.1.6 I'm
The glassfish error INFO: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context '/NNTPjsf' INFO: WEB0671:
Glassfish had already been installed into Netbeans. But I forgot the password and username.
I have a Glassfish server in production which uses JDBC Realm for authentication. It
I just installed Glassfish on my Ubuntu server (No GUI) using THIS tutorial. Everything
I have trouble launching Glassfish v3 on Mac In Windows, after installation of Glassfish

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.