DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Configuring Document Cache Interval

  • 1.  Configuring Document Cache Interval

    Posted Mon January 22, 2024 11:20 AM

    Hi. 

    Is there a way we can control the Cache Interval value based on the input request content. My use case is to store the token in Cache of Datapower service. Along with token, the validity of token will be sent in the response. Is there any way , the document cache Interval can be configured based on the validity of token?



    ------------------------------
    R K
    ------------------------------


  • 2.  RE: Configuring Document Cache Interval

    Posted Mon January 22, 2024 12:11 PM

    Which cache?  API, OAuth, Kerberos, etc?  

    Generally speaking, though you can explicitly invalidate and flush documents in the cache, I'm not sure if you can set individual caching intervals within DataPower's cache.   You can code against the TTL of the token (if you are indeed storing in something like an encrypted or signed cookie) and explicitly invalidate and flush based upon that, provided the key is unique. 

    This is the domain of something more capable like eXtreme Scale, which allows setting an explicit expiration (TTL) per key. 



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



  • 3.  RE: Configuring Document Cache Interval

    Posted Mon January 22, 2024 02:50 PM

    Thanks Joseph for the information. I am asking about document cache in MPGW Service. Is the TTL dynamically updated from the cache content in Datapower.



    ------------------------------
    R K
    ------------------------------



  • 4.  RE: Configuring Document Cache Interval

    Posted Mon January 22, 2024 04:22 PM

    You can group large numbers of tokens into particular categories related to TTL by URL.   See the "Document Caching Policy" of the XML Manager settings for your service.  If your tokens can be matched by URL, then you likely can.    But I don't see a way by the input context without something like eXtreme Scale or a not recommended hack.

    The "not recommended"  hack is to develop some kind of internal service to manage the cache; build an XML Manager dedicated to the service; then, in the main service, forward to the service with a URL built based upon the input data, maybe with TTL=XXX in the URL.  Then, in the XML Manager dedicated to that service, build the document caching around those URLs.



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



  • 5.  RE: Configuring Document Cache Interval

    Posted Tue January 23, 2024 03:16 PM

    Thanks for the information. Is there any integration of Datapower with Redis as we have Redis in our enterprise and can make use of Redis Cache if needed.



    ------------------------------
    R K
    ------------------------------



  • 6.  RE: Configuring Document Cache Interval

    Posted Tue January 23, 2024 04:06 PM

    Not out of the box, but there should be no reason you cannot integrate with it.



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



  • 7.  RE: Configuring Document Cache Interval

    Posted Tue January 23, 2024 02:38 AM

    If it is fit for your use case you can also try to invalidate the cache entries as part of your service flow execution using cache extension functions.



    ------------------------------
    Hermanni Pernaa
    ------------------------------



  • 8.  RE: Configuring Document Cache Interval

    Posted Wed January 24, 2024 09:22 AM

    Hi RT,

    Actually there is a way dynamically specify a document cache policy.  It's called dynamic caching policies.  Please see https://www.ibm.com/docs/en/datapower-gateway/10.5.0?topic=variables-varservicecachedynamic-policies for an example.  In code you will build an XML document that has your url and associated caching options, including in your case your dynamic TTL, and then that is placed into var://service/cache/dynamic-policies.  The API Connect v5 MPGW does exactly this with the invoke policy which is written in GatewayScript.  You could also do this in a xslt stylesheet.  The doc shows you simple examples of both.

    Now if you're asking if once a backend response has been received and thus cached based upon either an XML Manager or dynamic doc cache policy, can I inspect the response (ie, a token in that response) and change after the fact the expiry of the already cache entry, that isn't possible in DataPower, but I'd think in this case you should be using protocol caching where the backend, based on the token, would specify the expiry in its response headers that DataPower would use when adding the response to the cache.

    Best Regards,
    Steve



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



  • 9.  RE: Configuring Document Cache Interval

    Posted Wed January 24, 2024 09:55 AM

    Steve, 

    Are these policies extensions to any caching policy defined within an XML manager, or are they a complete override?  That is, let's say I have three URL's defined in an XML manager of a MPGW.   Then I load 3 different ones into the service variable.   Does the service variable override the definitions of the XML manager?

    Reading the documentation, it seems to be no different from the XML Manager document cache policy configuration, but maybe more convenient in a dynamically configured environment such as API Connect, when the policy might not be best statically configured.



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



  • 10.  RE: Configuring Document Cache Interval

    Posted Wed January 24, 2024 10:50 AM

    Hi Joseph,
    You're correct that the dynamic policies are identical to what is in the XML Manager from a configuration viewpoint.  Any dynamic policies are in addition to what's in the XML manager.  If there is a collision with the url match with one in the static list, the dynamic policy would take precedence, but assuming the matching url is unique, it will simply be added to the list of policies during the execution of that transaction.
    Best Regards,
    Steve



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