Author: sshyrkov Date: Mon Oct 15 11:23:28 2007 New Revision: 807 URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D807&repname= =3Dcorporate_portal_templates_v2 Log: JAHIA-2528: Proper caching for static resources =
http://www.jahia.net/jira/browse/JAHIA-2528 Resolution: set 'Cache-control' and 'Expires' response headers to correctly= cache static resources under /jsp/jahia Modified: branches/JAHIA-5-0-SP-BRANCH/src/jsp/css/template_css.jsp branches/JAHIA-5-0-SP-BRANCH/src/jsp/javascript/transmenu_js.jsp Modified: branches/JAHIA-5-0-SP-BRANCH/src/jsp/css/template_css.jsp URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP= -BRANCH/src/jsp/css/template_css.jsp&rev=3D807&repname=3Dcorporate_portal_t= emplates_v2 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- branches/JAHIA-5-0-SP-BRANCH/src/jsp/css/template_css.jsp (original) +++ branches/JAHIA-5-0-SP-BRANCH/src/jsp/css/template_css.jsp Mon Oct 15 11= :23:28 2007 @@ -14,29 +14,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---%><%@ page language=3D"java" %><%@ taglib uri=3D"contentLib" prefix=3D"c= ontent" %><% +--%><%@ page language=3D"java" %><% response.setContentType("text/css"); - // this value can control the different parts of css (if needed) - String bv=3D""; - bv=3D(String)request.getParameter("bval"); - if(bv=3D=3Dnull || bv.equalsIgnoreCase("")) bv=3D"3"; - int bval=3DInteger.parseInt(bv); -org.apache.log4j.Logger logger =3D org.apache.log4j.Logger.getLogger(getCl= ass()); -org.jahia.settings.SettingsBean siteSetting =3D org.jahia.bin.Jahia.getSet= tings(); -if (siteSetting !=3D null) { - if (siteSetting.isDevelopmentMode()) { - logger.debug("We are in dev mode -> Disable browser cache for temp= late_css.jsp"); - response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 - response.setHeader("Pragma","no-cache"); //HTTP 1.0 - response.setDateHeader ("Expires", -1); - } else { - logger.debug("We are in production mode -> Set browser cache for t= emplate_css.jsp to 1 hour"); - long now =3D System.currentTimeMillis(); - response.setDateHeader("Expires", now + 3600000); // 1 hour - response.addHeader("Cache-Control", "max-age=3D3600"); - } -} -logger.debug("Opening template_css.jsp"); +String ctx =3D request.getContextPath(); +org.jahia.settings.SettingsBean siteSetting =3D org.jahia.bin.Jahia.getSet= tings(); +if (siteSetting !=3D null && siteSetting.isDevelopmentMode()) { + response.setHeader("Cache-Control","no-store, no-cache, must-revalidat= e, max-age=3D0"); //HTTP 1.1 + response.addHeader("Cache-Control","post-check=3D0, pre-check=3D0"); + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", -1); +} else { + response.setHeader("Cache-Control", "public, max-age=3D604800, post-ch= eck=3D7200, pre-check=3D604800"); + response.setHeader("Pragma", ""); + response.setDateHeader("Expires", System.currentTimeMillis() + 604800 = * 1000); // 7 days +} %>/* GLOBAL SETTINGS ------------------------------------------------ */ body{background:#ddd;color:#333;font-family:Arial, Helvetica, sans-serif;f= ont-size:11px;text-align:left;margin:0;padding:0;} @@ -373,9 +364,9 @@ table.searchResultListing th a,table.searchResultListing th a:visited{colo= r:#000;} table.searchResultListing th a:hover{color:#000;text-decoration:underline;} table.searchResultListing th.sorted a,table.searchResultListing th.sortabl= e a{background:right top;display:block;width:100%;} -table.searchResultListing th.sortable a{background:url(<content:serverHttp= Path/>/jsp/jahia/engines/images/arrow_off.png) no-repeat;padding-right:5px;} -table.searchResultListing th.order1 a{background:url(<content:serverHttpPa= th/>/jsp/jahia/engines/images/arrow_down.png) no-repeat;padding-right:5px;} -table.searchResultListing th.order2 a{background:url(<content:serverHttpPa= th/>/jsp/jahia/engines/images/arrow_up.png) no-repeat;padding-right:5px;} +table.searchResultListing th.sortable a{background:url(<%=3Dctx%>/jsp/jahi= a/engines/images/arrow_off.png) no-repeat;padding-right:5px;} +table.searchResultListing th.order1 a{background:url(<%=3Dctx%>/jsp/jahia/= engines/images/arrow_down.png) no-repeat;padding-right:5px;} +table.searchResultListing th.order2 a{background:url(<%=3Dctx%>/jsp/jahia/= engines/images/arrow_up.png) no-repeat;padding-right:5px;} table.searchResultListing tr.odd{background:#ecf7ce;} table.searchResultListing tr.even{background:#fff;} div.searchResultListing span.pagelinks a{display:inline;} @@ -469,9 +460,9 @@ table.formResultListing th a,table.formResultListing th a:visited{color:#0= 00;} table.formResultListing th a:hover{color:#000;text-decoration:underline;} table.formResultListing th.sorted a,table.formResultListing th.sortable a{= background:right top;display:block;width:100%;} -table.formResultListing th.sortable a{padding-left: 12px; background:url(<= content:serverHttpPath/>/jsp/jahia/engines/images/arrow_off.png) no-repeat;= padding-right:5px;} -table.formResultListing th.order1 a{background:url(<content:serverHttpPath= />/jsp/jahia/engines/images/arrow_down.png) no-repeat;padding-right:5px;} -table.formResultListing th.order2 a{background:url(<content:serverHttpPath= />/jsp/jahia/engines/images/arrow_up.png) no-repeat;padding-right:5px;} +table.formResultListing th.sortable a{padding-left: 12px; background:url(<= %=3Dctx%>/jsp/jahia/engines/images/arrow_off.png) no-repeat;padding-right:5= px;} +table.formResultListing th.order1 a{background:url(<%=3Dctx%>/jsp/jahia/en= gines/images/arrow_down.png) no-repeat;padding-right:5px;} +table.formResultListing th.order2 a{background:url(<%=3Dctx%>/jsp/jahia/en= gines/images/arrow_up.png) no-repeat;padding-right:5px;} table.formResultListing tr.odd{background:#ecf7ce;} table.formResultListing tr.even{background:#fff;} div.formResultListing span.pagelinks a {display: inline;} @@ -486,9 +477,9 @@ table.revisionsListing th a,table.revisionsListing th a:visited {color: bl= ack;} table.revisionsListing th a:hover {text-decoration: underline;color: black= ;} table.revisionsListing th.sorted a,table.revisionsListing th.sortable a {b= ackground-position: right top;display: block;width: 100%;} -table.revisionsListing th.sortable a {padding-right: 5px;background-image:= url(<content:serverHttpPath/>/jsp/jahia/engines/images/arrow_off.png);back= ground-repeat:no-repeat;} -table.revisionsListing th.order1 a {padding-right: 5px;background-image: u= rl(<content:serverHttpPath/>/jsp/jahia/engines/images/arrow_down.png);backg= round-repeat:no-repeat;} -table.revisionsListing th.order2 a {padding-right: 5px;background-image: u= rl(<content:serverHttpPath/>/jsp/jahia/engines/images/arrow_up.png);backgro= und-repeat:no-repeat;} +table.revisionsListing th.sortable a {padding-right: 5px;background-image:= url(<%=3Dctx%>/jsp/jahia/engines/images/arrow_off.png);background-repeat:n= o-repeat;} +table.revisionsListing th.order1 a {padding-right: 5px;background-image: u= rl(<%=3Dctx%>/jsp/jahia/engines/images/arrow_down.png);background-repeat:no= -repeat;} +table.revisionsListing th.order2 a {padding-right: 5px;background-image: u= rl(<%=3Dctx%>/jsp/jahia/engines/images/arrow_up.png);background-repeat:no-r= epeat;} table.revisionsListing tr.odd {background-color: #fff} table.revisionsListing tr.tableRowEven,tr.even {background-color: #fea} table.revisionsListing {padding:0px;width: 100%;margin-left: -2px;margin-r= ight: -2px;} Modified: branches/JAHIA-5-0-SP-BRANCH/src/jsp/javascript/transmenu_js.jsp URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP= -BRANCH/src/jsp/javascript/transmenu_js.jsp&rev=3D807&repname=3Dcorporate_p= ortal_templates_v2 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- branches/JAHIA-5-0-SP-BRANCH/src/jsp/javascript/transmenu_js.jsp (origi= nal) +++ branches/JAHIA-5-0-SP-BRANCH/src/jsp/javascript/transmenu_js.jsp Mon Oc= t 15 11:23:28 2007 @@ -14,10 +14,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. = See the License for the specific language governing permissions and = limitations under the License. ---%><%@ page language=3D"java" %> -<%@ page import=3D"java.util.*" %> -<% +--%><%@ page language=3D"java" %><%@ page import=3D"java.util.*" %><% response.setContentType("application/x-javascript"); +response.setHeader("Cache-Control", "public, max-age=3D604800, post-check= =3D7200, pre-check=3D604800"); +response.setDateHeader("Expires", System.currentTimeMillis() + 604800 * 10= 00); // 7 days String contextUrl =3D request.getContextPath() + request.getServletPath(); contextUrl =3D contextUrl.substring(0,contextUrl.lastIndexOf("/") ); %> _______________________________________________ cvs_list mailing list [email protected] http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list
