Rank: Enthusiast
Joined: 8/31/2007 Posts: 37 Location: Utrecht NL
|
I made a macro which sets the Last-modified http header of Umbraco pages to Umbraco's @updateDate. This caches unmodified pages on the client side, which improves speed and reduces bandwidth on the server. I thought this might be interesting for others, or someone has an even better method? Below is the basic pinciple. I did make a more advanced version that also takes the updateDate from childnodes, which are displayed as menu items on my pages - so these should also trigger a new Last-modified date. But for clearity, the below example is only for the current page:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:hua="abc:yoursite-com:xslt" exclude-result-prefixes="msxml umbraco.library abc"> ... <xsl:value-of select="abc:setModif($currentPage/@updateDate)"/> ... <msxsl:script language="VB" implements-prefix="abc"> <msxsl:assembly name="System.Web"/> <!-- assembly reference generates error while saving, so use Skip testing (ignore errors) - not ideal though... --> <![CDATA[ public Function setModif(dat As String) Dim mDat As DateTime = Convert.ToDateTime(dat).ToUniversalTime System.Web.HttpContext.Current.Response.AddHeader("Last-modified", mDat.ToString("r")) 'Return mDat.ToString("r") 'use for debugging Return "" End Function ]]> </msxsl:script> </xsl:stylesheet>
|