You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2021/03/20 09:07:08 UTC

[myfaces] branch 2.3-next updated: MYFACES-4371 Resources: set cache-control-header instead of expires-header

This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch 2.3-next
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/2.3-next by this push:
     new 6b82ec6  MYFACES-4371 Resources: set cache-control-header instead of expires-header
     new fa62f86  Merge pull request #186 from christophs78/2.3-next-4817_ResourcesCacheControl
6b82ec6 is described below

commit 6b82ec682e98d200c9d45eed7b7e1ea8872f0073
Author: Christoph Straßer <ch...@gmail.com>
AuthorDate: Sun Mar 14 17:29:41 2021 +0100

    MYFACES-4371 Resources: set cache-control-header instead of expires-header
---
 impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java b/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
index c36ca38..a2aa86f 100644
--- a/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
@@ -194,18 +194,15 @@ public class ResourceImpl extends Resource implements ContractResource
             if (lastModified >= 0)
             {
                 headers.put("Last-Modified", ResourceLoaderUtils.formatDateHeader(lastModified));
-                
-                long expires;
+
                 if (facesContext.isProjectStage(ProjectStage.Development))
                 {
-                    // Force to expire now to prevent caching on development time.
-                    expires = System.currentTimeMillis();
+                    headers.put("Cache-Control", "no-cache");
                 }
                 else
                 {
-                    expires = System.currentTimeMillis() + _resourceHandlerSupport.getMaxTimeExpires();
+                    headers.put("Cache-Control", "max-age=" + (_resourceHandlerSupport.getMaxTimeExpires()/1000));
                 }
-                headers.put("Expires", ResourceLoaderUtils.formatDateHeader(expires));
             }
             
             return headers;