Layer 7 API Management

Expand all | Collapse all

Add Cache-Control header when using "Response: Look Up in Cache" Assertion

Jump to Best Answer
  • 1.  Add Cache-Control header when using "Response: Look Up in Cache" Assertion

    Posted 13 days ago
    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

    Posted 12 days ago
    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 9 days ago
    Edited by Louie Kwan 5 days ago
    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 5 days ago
    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

    Posted 5 days ago
    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 5 days ago
    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

    Posted 5 days ago
    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 5 days ago
    Edited by Louie Kwan 5 days ago
    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

    Posted 5 days ago
      |   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)