DataPower

 View Only
  • 1.  dp:invalidate-cached-documents()

    Posted 17 days ago

    Has anyone has an example on the gateway script for the 

    dp:invalidate-cached-documents() function?

    I tried in xslt and it is not working. Any suggestions are greatly appreciated. I have to invalidate the cache entry if one of the api matches and I dont see the document id is getting removed when I look at the document status in DataPower. Here is my xslt.

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:dp="http://www.datapower.com/extensions"
    xmlns:dpconfig="http://www.datapower.com/param/config" extension-element-prefixes="dp" exclude-result-prefixes="dp dpconfig">

    <xsl:variable name="dpDomainName" select="dp:variable('var://service/domain-name')"/>
    <xsl:variable name="dpXMLManagerName" select="dp:variable('var://service/xmlmgr-name')"/>
    <xsl:variable name="dpURI" select="dp:variable('var://service/URI')"/>
    <xsl:variable name="securityToken">
    <xsl:value-of select="dp:http-request-header('securityToken')"/> <!-- 94500D8B17E64A38A21B128C336C2BD0-->
    </xsl:variable>
    <xsl:variable name="dpCachePattern">
    <xsl:value-of select="'*'"/>
    </xsl:variable>
    <xsl:param name="dpconfig:sessionEndpoint" select="'http://DEVF1_localhost:9008'"/>

    <xsl:template match="/">
    <xsl:variable name="CallEndPoint" select="normalize-space($dpconfig:sessionEndpoint)"/>
    <xsl:variable name="AuthEndPoint" select="concat($CallEndPoint,'/CWValidateAuthToken?',$securityToken)"/>

    <xsl:choose>
    <xsl:when test="contains($dpURI,'/session/impersonate')">
    <xsl:variable name="dpCacheValues" select="dp:invalidate-cached-documents($dpDomainName, $dpXMLManagerName, $AuthEndPoint, $dpCachePattern)"/>
    <xsl:if test="$dpCacheValues &gt; 0">
    <xsl:message>Found entries and invalidated</xsl:message>
    </xsl:if>
    </xsl:when>
    <xsl:otherwise/>
    </xsl:choose>

    </xsl:template>
    </xsl:stylesheet>


    ------------------------------
    Suresh Sanga
    ------------------------------


  • 2.  RE: dp:invalidate-cached-documents()

    IBM Champion
    Posted 17 days ago

    I'd have to check, but just because they're invalidated doesn't mean they are flushed, so they may not be removed.  Do you want to invalidate or flush?  If you flush, try dp:flush-documents or dp:flush-expired-documents?

    If you are just invalidating, and that is not working, are you sure your variables contain the correct values?

    If so, have you tried by hand via, say, the web UI to invalidate and typing in the expected values?



    ------------------------------
    Joseph Morgan
    ------------------------------



  • 3.  RE: dp:invalidate-cached-documents()

    Posted 14 days ago

    If you are just invalidating, and that is not working, are you sure your variables contain the correct values?



    ------------------------------
    rikaz khan
    ------------------------------



  • 4.  RE: dp:invalidate-cached-documents()

    Posted 13 days ago

    To be clear to other users, this was addressed in the case.  The variable dpCachePattern (last parameter of invalidate-cached-documents) is supposed to be based on a x-dp-cache-key header from the request.  In this instance the customer is using asterisk '*' which is not a valid cache key.  Supplying an empty string, omitting the field altogether or an exact match to a x-dp-cache-key value is required.  When properly supplying this, the matching documents are put in an expired state and can be replaced when the service has a transaction that triggers the check of the url/cache.



    ------------------------------
    DOMINIC MICALE
    ------------------------------



  • 5.  RE: dp:invalidate-cached-documents()

    Posted 12 days ago

    Hi Suresh,
    To add to what Dominic said and looking at https://www.ibm.com/docs/en/datapower-gateway/10.5.0?topic=functions-dpinvalidate-cached-documents, the syntax is
    dp:invalidate-cached-documents(domain, manager, URL-match, cache-key)

    So your matching string should be in the 3rd argument where an * would be a match all urls in the document cache. The cache key is meant to be additional key information that would distinguish multiple identical document cache urls to be separate document cache entries.  Just a brief look at your code, but it would seem that your security token would be that cache key?  I don't know how you're putting responses into your document cache, but do you really have an outbound HTTP request that has something like https://host:port/someuri?94500D8B17E64A38A21B128C336C2BD0 ??  I'd look at your document cache status to see the actual URLs and cachekeys that are in the cache so these function arguments will mimic the way the documents were saved into the cache.
    Regards,
    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------