cdp-cache icon indicating copy to clipboard operation
cdp-cache copied to clipboard

Fix 3xx responses from upstream

Open danlsgiga opened this issue 5 years ago • 6 comments

Close #33

  • Reply to the client with the correct response status code
  • Use a better, more specific defaultCacheKeyTemplate to exact matches on resources that are redirected.
  • The other changes are my VSCode editor removing white spaces
  • Changes how the file backend store the files by using sha256 hashes based on the entry keyWithRespectVary() content. This way, we don't waste storage space by creating duplicated temporary files every time the caddy process is restarted.
  • Implemented the Length() function for the file backend, since some browsers have grief when the Content-Length is set to 0 and abort the operation causing the http request to have an empty body
  • Fix some tests

danlsgiga avatar Oct 09 '20 20:10 danlsgiga

Hi @danlsgiga! After reading your issue I wonder, does this PR make caching work for 30x responses or does it completely disable catching on those?

fgilio avatar Oct 26 '20 10:10 fgilio

hi @fgilio, yeah... basically, 3xx responses are redirection only and what was happening is that I was getting 302's from the upstream but the cache was responding with a 200 and the http redirection never happened since the browser only reads the new Location: header if the response is 301 or 302.

danlsgiga avatar Oct 26 '20 15:10 danlsgiga

Also, I'm sorry for the failing tests... I started using the memory backend but soon I started to get huge memory usages, probably memory leaking too, and moved to the file backend and made a few adjustments there too.

danlsgiga avatar Oct 26 '20 15:10 danlsgiga

hi @fgilio, yeah... basically, 3xx responses are redirection only and what was happening is that I was getting 302's from the upstream but the cache was responding with a 200 and the http redirection never happened since the browser only reads the new Location: header if the response is 301 or 302.

Hi @danlsgiga ,

Thanks for your work. I've fixed this bug in another pull request so this pr need to be updated.

sillygod avatar Dec 13 '20 03:12 sillygod

@sillygod any chances we can get the other features I added merged?

- Changes how the file backend store the files by using sha256 hashes based on the entry keyWithRespectVary() content. This way, we don't waste storage space by creating duplicated temporary files every time the caddy process is restarted.
- Implemented the Length() function for the file backend, since some browsers have grief when the Content-Length is set to 0 and abort the operation causing the http request to have an empty body

danlsgiga avatar Jan 12 '21 17:01 danlsgiga

@sillygod any chances we can get the other features I added merged?

- Changes how the file backend store the files by using sha256 hashes based on the entry keyWithRespectVary() content. This way, we don't waste storage space by creating duplicated temporary files every time the caddy process is restarted.
- Implemented the Length() function for the file backend, since some browsers have grief when the Content-Length is set to 0 and abort the operation causing the http request to have an empty body

Sorry for replying so late, I'll check it today.

Furthermore, would you please fix the failed test? I've seen that the file backend's schema is changed so the relevant tests should be revised.

sillygod avatar Jan 13 '21 01:01 sillygod