[CacheResponsesPlugin] Support serving out of cache #792
Replies: 19 comments
-
On the outset it appears as a straight forward approach to map the cached content to the saved url. Is that the only thing that needs to be done? Can you elaborate the production grade requirement? |
Beta Was this translation helpful? Give feedback.
-
Cache invalidation is the key for production grade caching solutions. E.g. Upstream servers will serve a URL with some cache control/expiry headers. An ideal cache server must invalidate cache and fetch/serve fresh response after cache expiry. Over the course of HTML specification upgrades, there are just too many cache headers to take care of e.g. |
Beta Was this translation helpful? Give feedback.
-
That would mean replicating the entire HTTP cache protocol with active support for specification changes over every new releases? |
Beta Was this translation helpful? Give feedback.
-
Not necessarily. We can start adding subset of features (enabled explicitly via flags) as needed by the community. Probably also a good idea to add references to section(s) of RFC that cache plugin implements in the documentation. Happy to discuss if you have any particular scenario in mind. |
Beta Was this translation helpful? Give feedback.
-
If we start small, from where must we begin? |
Beta Was this translation helpful? Give feedback.
-
@ja8zyjits Yep that's the RFC we can follow. Ideally, we must pick a use case that your application currently needs. If you would like to start working towards it generically, I'll recommend following steps:
Let me know where you would like to start. Thank you!!! |
Beta Was this translation helpful? Give feedback.
-
@abhinavsingh sure, would look into them. |
Beta Was this translation helpful? Give feedback.
-
What's the point to store chunks and never deliver them for the same given request ? I guess it's most a logging plugin instead of caching one :) |
Beta Was this translation helpful? Give feedback.
-
Correct, unless we start to dispatch back responses to the client, it's a logging plugin, so yes However, how to start serving response back out of cache is precisely what @ja8zyjits is working towards. We have discussed in some detail why |
Beta Was this translation helpful? Give feedback.
-
Just my 2 cents... Even tho it feels logical to respect caching policies and headers in HTTP proto to handle caching in proxy server, for my usecase, it would be wonderful to have KV-based caching. This is why I started to use this product in the first place. Attempted to use... and failed. |
Beta Was this translation helpful? Give feedback.
-
Hi Denis,
Correct, CacheResponsesPlugin like any other plugin within proxy.py
distribution is merely an example.
Existing plugin can be expanded upon to add application specific
functionalities. E.g. CacheResponsesPlugin is built on top of
BaseStore *(abstract
layer for caching backends*). You can write your own for custom backends.
Let me know how it goes.
Thank you
Abhinav
…On Tue, Jun 23, 2020, 12:10 AM Denis Tomilin ***@***.***> wrote:
Just my 2 cents...
By definition caching felt like it should actually cache the results. But
feels like instead of caching, it just dumps the data like tcpdump(correct
me if caching plugin actually does something...), which has nothing to do
with actual caching.
Even tho it feels logical to respect caching policies and headers in HTTP
proto to handle caching in proxy server, for my usecase, it would be
wonderful to have KV-based caching. This is why I started to use this
product in the first place. Attempted to use... and failed.
Feels like I'll need to write my own plugin then.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#319 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA6Y4MSKZRAFT2ZD3QW4U3RX6QRZANCNFSM4LSZWTAA>
.
|
Beta Was this translation helpful? Give feedback.
-
Hi Denis,
Normal KV store cache breaks the site, specially when their js scripts
expires. I have tried it and it fails. We need something that works like
squid. Caches but also follows the protocols. Unfortunately some sites
would not allow any caching eg: YouTube. They use all protocols to expire
caches or not let them be stored.
…On Tue, 23 Jun 2020, 00:10 Denis Tomilin, ***@***.***> wrote:
Just my 2 cents...
By definition caching felt like it should actually cache the results. But
feels like instead of caching, it just dumps the data like tcpdump(correct
me if caching plugin actually does something...), which has nothing to do
with actual caching.
Even tho it feels logical to respect caching policies and headers in HTTP
proto to handle caching in proxy server, for my usecase, it would be
wonderful to have KV-based caching. This is why I started to use this
product in the first place. Attempted to use... and failed.
Feels like I'll need to write my own plugin then.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#319 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACSGU6IEUBQAM22A4M4HCCLRX6QR3ANCNFSM4LSZWTAA>
.
|
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
@pasccom For test cases, I previously took a stab at similar feature. Idea was to record and replay responses by enabling See https://github.com/abhinavsingh/proxy.py/blob/develop/proxy/testing/test_case.py#L80 and https://github.com/abhinavsingh/proxy.py/blob/develop/tests/testing/test_embed.py#L56. It's pretty incomplete and will require more work for e2e correctness. Probably you already implemented some of those feature sets. Internally I envisioned something like this:
Please propose your implementation in a PR. I would like to better understand reasons behind modifications within Best |
Beta Was this translation helpful? Give feedback.
-
Also see related issue tracker for VCR functionality #184 |
Beta Was this translation helpful? Give feedback.
-
Thinking of it, serving out of cache for test cases can also be a clone of Throwing a few options that can inspire implementation of this feature set 👍 |
Beta Was this translation helpful? Give feedback.
-
For HTTP requests, yes, it does. But, I needed to intercept HTTPS requests, which did not work. I will test with I will test my implementation on the |
Beta Was this translation helpful? Give feedback.
-
Hello, I think there is still some work to be done for it to work correctly (even for HTTP requests):
I will write some more thorough tests tomorrow, implement the missing features and create a PR. |
Beta Was this translation helpful? Give feedback.
-
@pasccom Cool.
|
Beta Was this translation helpful? Give feedback.
-
Currently cache_responses.py plugin only caches but doesn't serves out of cached data.
Per @trianta2 request here it will be a good idea to support this in future releases.
However, for a production grade usage, this feature will require significant work. If someone is interested in taking a stab at this one, please feel free to reach out. Happy to discuss it further.
Beta Was this translation helpful? Give feedback.
All reactions