{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
1

Cache handling in proxies which return both XML and JSON response  

  • Export to PDF
Raunak Narooka   created · Oct 30, 2017 at 06:05 PM · 315 Views · edited · Oct 30, 2017 at 06:05 PM

Suppose you get a scenario where you have to design a proxy which gives a JSON response or XML response based on the 'Accept' Header. If the user of the proxy sends, Accept header = application.json, you should gives JSON response, if he sends application/xml, you should guve XML response. If you have added a response cache in such a proxy, you will run into some issues

1.) If the user expects a JSON response, a JSON output would be stored in the cache.

2.) Now when the user expects an XML response, because the response cache is present in both the request and response flow, it will first hit the response cache and you will get a JSON response instead of an XML response.

The solution to this, is to use a small but a valuable property while configuring response cache. <UseAcceptHeader>true</UseAcceptHeader>

In this case, the accept header would be suffixed to your cache key, which will help the cache distinguish between different types of responses.

thub.nodes.view.add-new-comment
api proxyedgecachecachingresponse cacheedge architecture
Add comment Show 1
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sid · Nov 01, 2017 at 01:42 AM 1
Link

Thanks @Raunak Narooka Great Info !!

Article

Contributors

avatar image

Follow this article

62 People are following this .

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Navigation

Apigee Edge Caching In Detail
  • Cache handling in proxies which return both XML and JSON response

Related Articles

Apigee Edge Caching In Detail

Customized APIs by device - Belly

Sample: Using Node.js caching with Edge policies

Tutorial: Implementing Response Caching within Edge

How to dynamically call different target endpoints based on region

Apigee Developer? Here's The Stuff You Should Know

Using the ResponseCache policy responsibly! (or, Don't cache POST requests)

Automate KVM creation on Apigee Edge

Quick way to find the Developer App associated with a particular Consumer Key

Handling invalid Resource Paths using a default Resource and the Raise Fault policy

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges