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:06:46 UTC
[myfaces] branch 2.3.x 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.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/2.3.x by this push:
new 89ee5da MYFACES-4371 Resources: set cache-control-header instead of expires-header
new 1dc7172 Merge pull request #187 from christophs78/2.3.x-4817_ResourcesCacheControl
89ee5da is described below
commit 89ee5da081a7ac5bcfb1f6b67fa3005207e8eacc
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
---
.../java/org/apache/myfaces/shared/resource/ResourceImpl.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java b/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java
index 8f3322c..1563beb 100644
--- a/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java
+++ b/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java
@@ -193,18 +193,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;