Unable to apply Javascript XSL Transform over HTTPS
Jan 28th, 2008 by Stephen Downey
I came across this issue a while a go and couldn’t really find much information on it at the time so thought that I would post about it just in case anyone has a similar issue.
We had the following code that loads an XML document and then applies a XSL transform against the XML document. The code looks a bit like following:
(This is the IE Specific version)
xmlDoc = new ActiveXObject(’Msxml2.DOMDocument.3.0′);
xmlDoc.loadXML(XMLString);
xslDoc = new ActiveXObject(’Msxml2.DOMDocument.3.0′);
xslDoc.load(xslFile);
output = xmlDoc.transformNode(xslDoc);
We would normally run this over HTTP and it always applied the transform and generated our output as you would expect. When we ran the same code over HTTPS the transform would never work.
After a lot of investigation it turned out that the issue was being caused due to a cache setting in the response header.
We were setting the Cache-Control parameter in the Response header to
‘private,no-cache,no-store’.
It seems that not allowing the XSL form to be cached was preventing the ActiveObject from loading it for the transform. By removing Cache-control parameter from the response header it worked fine every time.
Hope this can save someone with the same issue a bit of time.
Thanks for this. I was in the middle of posting an update to our live website when I came across this problem. With clients patiently waiting for the modifications to be completed – I simply removed the header for the xsl file I was trying to load and the problem was fixed. Thanks again.
@ Chris,
Glad it helped, I know I spent a few days trying to find a solution when it happened to me.