Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] Response Caching #411

Closed
sonicaghi opened this issue Jul 18, 2015 · 26 comments
Closed

[request] Response Caching #411

sonicaghi opened this issue Jul 18, 2015 · 26 comments
Labels
idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports.

Comments

@sonicaghi
Copy link
Member

Able to cache the response of specific API calls, for a specified amount of time.

@sonicaghi sonicaghi added idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports. request labels Jul 18, 2015
@subnetmarco
Copy link
Member

To implement response caching we need to parse the HTTP caching headers and properly store the cached items in-memory (in a nginx dict) or optionally in the datastore.

@subnetmarco
Copy link
Member

This is also an interesting project that solves the caching problem: https://github.com/pintsized/ledge (but the problem is that it uses redis). We could take some inspiration from it especially for the HTTP headers parsing.

@samek
Copy link

samek commented Aug 17, 2015

@thefosk It would be nice if you could enable caching based on path as well what ever the header from the upstream is.

like:
/api/user/get = 0 sec
/api/article/get = 10 sec ..

@sonicaghi
Copy link
Member Author

@samek if this is going to be a plugin then all plugins will have setting per: api, endpoint, consumer, organization, path, etc

@lindo-jmm
Copy link

Note: Consider using Redis

@naoko
Copy link

naoko commented Jan 9, 2016

there is this circular referencce and I couldn't reach anywhere....

#749 -----> #411    <----|
         <-----|         |
         -----> #412     |
         <-----|         |
               |------> #830

@bjcooper
Copy link

bjcooper commented Apr 15, 2016

I agree with @naoko, there seems to be a confusing circle of references to this topic. However, I believe this is the official issue (#411) for the topic of response caching. Others looking for info on this, look no further.

I'm kicking myself for not doing better research before jumping in with Kong, but now that I've got it set up and going I'm sorry to find it doesn't actually offer any response caching/cache invalidation.

Many of the diagrams used to market Kong are misleading (check the "Kong Architecture" diagram on the getkong.org front page, for example). They list "caching" as one of the things Kong can do in front of your APIs, but this appears to be flatly untrue at the moment. Someone please tell me I'm overlooking something!

@ahmadnassri ahmadnassri added the BC label May 13, 2016
@thibaultcha thibaultcha mentioned this issue Jun 24, 2016
@wshirey
Copy link

wshirey commented Aug 2, 2016

I am very interested in this feature and wouldn't mind pitching in. I think it's a feature that would definitely help increase adoption rate. Not familiar with the BC label, but chiming in here to add my +1 and bump up the priority.

@marklkelly
Copy link

+1 for response caching.

@CodeTripper
Copy link

+1 for caching

@ahamedm
Copy link

ahamedm commented Aug 26, 2016

+1 for response caching with more control on eviction and request patterns

@thibaultcha thibaultcha removed the BC label Sep 1, 2016
@jeanpralo
Copy link

def keen on response caching !

@mrmichaeladavis
Copy link

+1

@greenieweinee
Copy link

@thefosk @sinzone is there any chance we can get an update on if/when this plugin would be developed? my company is making a deceision on kong vs other options and this would be a fairly important factor. thanks!

@subnetmarco
Copy link
Member

@greenieweinee we don't have any short term plan for now - but you can maybe leverage the underlying nginx process or use a third-party caching system between Kong and the final API.

@IvanVas
Copy link

IvanVas commented Jan 4, 2017

+1

@se
Copy link

se commented Jan 4, 2017

+1 ^^

@IvanVas
Copy link

IvanVas commented Jan 10, 2017

I tried to enable caching using custom ngnix config for kong (as suggested). Worked, but it disabled all Kong plugins for that API.

@di97mni
Copy link

di97mni commented Jan 10, 2017

What if you put Varnish, or any other HTTP Cache, behind Kong?

@bjcooper
Copy link

That's what I've done (not obviously part of Kong):

Kong <--> Varnish <--> Origin API endpoints

@wshirey
Copy link

wshirey commented Jan 23, 2017

I have started a POC plugin for caching here. It caches responses based on URL patterns in redis, but could be applied more granularly with the new routing in 0.10. Could be abstracted to use the policies pattern in rate-limiting plugin for different store implementation.

I plan on including ability to specify headers and query params for computing cache key.

https://github.com/wshirey/kong-plugin-response-cache

@IvanVas
Copy link

IvanVas commented Jan 24, 2017

Nice, @wshirey! If responses pool is not too big, Redis would be an overkill though. In-mem or file storage (as nginx does it) would be preferable in this case, I recon.

@subnetmarco
Copy link
Member

Hi @wshirey - nice. It would be nice if the plugin could autonomously follow the response HTTP caching headers returned by the API, and then cache appropriately the response, ie:

  • Cache-Control
  • Last-Modified
  • ETag

@wshirey
Copy link

wshirey commented Jan 26, 2017

@thefosk Honestly, I'm not sure I would add that myself, since I'm not that familiar with all the caching headers and wouldn't be using caching headers on my upstream APIs.

@thibaultcha
Copy link
Member

thibaultcha commented Jan 26, 2017

It would only make sense to widely release such a plugin if it is implemented in a standardized and un-opinionated way. Hence, it is crucial for it to respect the HTTP caching headers, or else it would be unusable for most people out there...

@p0pr0ck5
Copy link
Contributor

p0pr0ck5 commented Oct 23, 2017

This is now available as part of Kong Enterprise! https://getkong.org/plugins/ee-proxy-caching/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports.
Projects
None yet
Development

No branches or pull requests