简体   繁体   中英

Caching client-side XSLT imports in Internet Explorer

I'm transforming an XML document with XSLT in Internet Explorer 7. My XSLT imports/includes -- I've tried both -- another XSLT with the following line:

<xsl:import href="utils.xsl" />

This results in an HTTP request for the included file every time the including XSLT is used, even if a reference to the parent XSLT is cached and re-used. IE sends a Pragma: no-cache header on each request for the import/include request.

Is it possible to prevent these repeated HTTP requests?

  • Can I get IE to cache the file in the client?
  • If not, can I get IE to send an "If-Modified-Since" header?

For completeness, here's the corresponding transformation JavaScript:

var XMLUtil = {

    // transforms the sourceStr using the given xslDoc
    transformString: function(sourceStr, xslDoc /*XMLDOM doc*/) {
        var sourceDoc = XMLUtil.loadFromString(sourceStr);
        var resultDoc = new ActiveXObject("Microsoft.XMLDOM");
        sourceDoc.transformNodeToObject(xslDoc, resultDoc);
        return resultDoc;
    },

    // creates an XMLDOM document from a string containing XML
    loadFromString: function(xml) {
        var doc = new ActiveXObject("Microsoft.XMLDOM");
        doc.async = false;
        doc.loadXML(xml);
        if (doc.parseError.errorCode != 0)
            throw "Error parsing XML: " + doc.parseError.errorCode;
        return doc;
    }

}

The responses to a similar question recommends setting ForcedResync to false.

But Qi Samuel Zhang's response cautions

ForcedResync should work for most cases, but the ForcedResync in MSXML3 has known issues to mitigate backward compatibility, please use MSXML2.DOMDocument.6.0 when possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM