Layer7 API Management

 View Only
  • 1.  Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Posted Oct 31, 2019 12:10 PM
    Using "Store to Cache" then "Response: Look Up in Cache" Assertions.

    It seems working fine but we have a need to add Cache-Control header when using "Response: Look Up in Cache" Assertion.

    I found no luck for that. For "Transport Properties/Headers Properties" is mainly for request, but not response message.

    Any tip will be much appreciated.

    Thanks.
    Louie Kwan
    AWS Certified Solutions Architect – Associate

    ------------------------------
    Enterprise Architect
    AWS Certified Solutions Architect – Associate

    ------------------------------


  • 2.  RE: Add Cache-Control header when using "Response: Look Up in Cache" Assertion
    Best Answer

    Broadcom Employee
    Posted Nov 01, 2019 06:46 AM
    Hi Louie.

    The Manage Transport Properties/Headers assertion is your best bet as you noted. Add the assertion and then right click on it and choose 'Select Target Message', change to response.

    ie:
    add response header

    browser response headers



  • 3.  RE: Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Posted Nov 04, 2019 10:52 AM
    Edited by Louie Kwan Nov 08, 2019 03:02 PM
    Thanks for your info. It works, but it seems all header info is not saved.

    It seems I can only save the body of the response and nothing in the header can be stored "Response: Look Up in Cache".

    This is a big limitation?

    Any tip to overcome this constraint?


    ------------------------------
    Enterprise Architect
    TwoCoins.ca Inc.
    ------------------------------



  • 4.  RE: Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Posted Nov 08, 2019 03:07 PM
    It seems I can only save the body of the response and nothing in the header can be stored "Response: Look Up in Cache".

    This is a big limitation?

    Any tip to overcome this constraint?


    ------------------------------
    Enterprise Architect
    TwoCoins.ca Inc.
    ------------------------------



  • 5.  RE: Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Broadcom Employee
    Posted Nov 08, 2019 03:14 PM
    That is correct. The cache ONLY saves the message body. If you need to save headers then you will need to store them in a separate cache using the same key value, then apply them using the "Transport Properties/Headers" assertion at runtime.

    ------------------------------
    Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
    ------------------------------



  • 6.  RE: Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Posted Nov 08, 2019 03:28 PM
    Thanks for your quick response.

    If I put two "Response: Look Up in Cache", it only take the first one. What you refer to separate cache, what cache you are referencing to ?

    Same Key and using 
    "Transport Properties/Headers" assertion at runtime should be fine.

    Thanks in advance.


    ------------------------------
    Enterprise Architect
    TwoCoins.ca Inc.
    ------------------------------



  • 7.  RE: Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Broadcom Employee
    Posted Nov 08, 2019 03:42 PM
    In the "Store to Cache" and "Look Up in Cache" assertions there is an option to set the Cache ID. It is set to defaultCache when you first open the assertions. Change the value in there to isolate the information that is cached. I usually change it from defaultCache any time I use the internal cache, anyway, just to ensure nothing gets clobbered accidentally. For example: messageCache and headerCache.

    Also be careful that when retrieving a value from a cache it comes out as a message type context variable, so the retrieved header value will need the .mainpart suffix when used in the "Transport Properties/Headers" assertion.

    ------------------------------
    Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
    ------------------------------



  • 8.  RE: Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Posted Nov 08, 2019 03:52 PM
    Edited by Louie Kwan Nov 08, 2019 04:35 PM
    Thanks for the tip. This community helps. Thanks Jay again.


    ------------------------------
    Enterprise Architect
    TwoCoins.ca Inc.
    ------------------------------



  • 9.  RE: Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Broadcom Employee
    Posted Nov 08, 2019 04:42 PM
      |   view attached
    Attached is an example policy to illustrate one way to do this. Publish a Web API service on the gateway at, say, /test then import this policy to it.

    Cheers!

    JayMac

    ------------------------------
    Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
    ------------------------------

    Attachment(s)

    xml
    HeaderCachingExample.xml   8 KB 1 version