Jump to content
Sign in to follow this  
keevil

Stop XSLT Caching

Recommended Posts

Hello, I am currently using the xsl:import tag. However we have noticed it is caching the XSL. This means that when we update the XSL that is being referenced too, we have to refresh each XSL that uses the referenced document. My question is there a way to stop caching? Below is an example of the code we are using: Main XSLT

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    <xsl:import href="errorCode.xsl"/>    <xsl:output indent="yes"/>    <xsl:param name="time_generated"/>    <xsl:template match="/getResponse">	    <response>		    <header>			    <!-- START - errorCode.xsl Results -->			    <xsl:call-template name="errorCode"/>			    <!-- END - errorCode.xsl Results -->			    <response_detail>				    <time_generated_unix/>				    <time_generated_date_time>					    <xsl:value-of select="$time_generated"/>				    </time_generated_date_time>			    </response_detail>			    <apikey_detail>				    <class/>				    <rate-limit-remaining/>				    <rate-limit-reset/>			    </apikey_detail>		    </header>		    <data>			    <xsl:copy-of select="payload/node()"/>		    </data>	    </response>    </xsl:template></xsl:stylesheet>

External XSL that is being referenced in the import:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">    <xsl:template name="errorCode">	    <!-- START - SAP Error Codes -->	    <xsl:choose>		    <xsl:when test="rcode = 0">			    <status>200</status>			    <message_detail>Test</message_detail>		    </xsl:when>		    <xsl:when test="rcode = 1">			    <status>401</status>			    <message_detail>Unauthorised – User Does Not exist</message_detail>		    </xsl:when>		    <xsl:when test="rcode = 3">			    <status>401</status>			    <message_detail>Unauthorised – User is not authorised to perform the				    operation</message_detail>		    </xsl:when>		    <xsl:when test="rcode = 4">			    <status>400</status>			    <message_detail>Bad request – No Data could be returned</message_detail>		    </xsl:when>		    <xsl:when test="rcode = 5">			    <status>400</status>			    <message_detail>Bad request – Invalid Data In request</message_detail>		    </xsl:when>		    <xsl:when test="rcode = 6">			    <status>202</status>			    <message_detail>Request for creation accepted but not yet completed</message_detail>		    </xsl:when>		    <xsl:when test="rcode = 7">			    <status>409</status>			    <message_detail>Conflict - Data is locked in another request</message_detail>		    </xsl:when>		    <xsl:when test="rcode = 8">			    <status>400</status>			    <message_detail>Bad request – Mandatory Field Not Specified</message_detail>		    </xsl:when>		    <xsl:when test="rcode = 9">			    <status>400</status>			    <message_detail>Bad request – Data is not unique</message_detail>		    </xsl:when>		    <!-- END - SAP Error Codes -->		    <!-- Catach All Other Error Codes Not Specified -->		    <xsl:otherwise>			    <status>400</status>			    <message_detail>SAP Unknown Error</message_detail>		    </xsl:otherwise>	    </xsl:choose>    </xsl:template></xsl:stylesheet>

Share this post


Link to post
Share on other sites

Depends heavily on the environment you're using the XSLT in (I assume you're not just letting the browser do it).Personally, I like to still have caching, but have it with a Last-Modified header that takes the maximum of the source and all known XSLTs involved. For this to be implemented efficiently though, you must also verify if the request is a conditional one, and return 304 without doing the processing. Again, how exactly do you go about implementing this depends on the environment (PHP, ASP.NET, C# (desktop), JAVA, etc.).

Share this post


Link to post
Share on other sites

We are using a Apigee, an API tool that is currently performing the import and transformation. And the caching is done by Apigee. I was wondering if there is something that i could put in the header that would stop the caching or make it refresh the cache once a day? Is this something you are talking about in your message above?

Share this post


Link to post
Share on other sites

I don't see Apigee having any XSLT transformation APIs. They just have APIs for fetching and modifying information from different sites... what am I missing?Anyhow, Apigee, or whatever is responsible for executing the XSLT transformation should also be responsible for caching. If they don't do this caching as described above, that's something you should tell them to do, unless they provide you with a way to do it yourself.What I was talking about above applies if you're executing the transformation with an XSLT processor on your own server, like if you use PHP's XSLTProcessor class or ASP.NET's System.Xml.Xsl namespace.

Share this post


Link to post
Share on other sites

Ok thank you very much. No Apigee does not have a API for XSLT transformations. We use Apigee to create custom API's and the XSL's that i would like to include with the import are hosted on there servers; however they are very strict about us being able to so such things. That is therefore why i would like to force refresh the cache from the XSLT itself. But i don't think this can be done. Thank you for your help.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...