opa icon indicating copy to clipboard operation
opa copied to clipboard

Issue-6642 Add http.send request attribute to ignore headers for caching key

Open rudrakhp opened this issue 1 year ago • 7 comments

Why the changes in this PR are needed?

Need to support exclusion of certain headers from http.send query cache key.

What are the changes in this PR?

  • A new attribute cache_ignored_headers in the http.send built in request object. Enables policy authors to define an exclusion list for headers to ignore while caching.
  • Modify key used by the HTTP request executor when building the cache key.
  • Unit tests for these changes.

Notes to assist PR review:

  • Note that if request attribute cache_ignored_headers changes but does not affect the final computed cache key, the results are still served from cache. This attribute is always excluded from the cache key.
  • If there is a change in the exclusion list that leads to change in the cache key (addition/removal of a header), a new cache key is generated which leads to a cache miss.

Further comments:

Resolves #6642

rudrakhp avatar Apr 04 '24 12:04 rudrakhp

Thanks for working on this. Here we are excluding certain headers from the key calculation. Is there a reason for that level of granularity? Why not exclude certain request object params themselves from the key calculation?

I would have to explore if there is any straight forward way to delete a value by path reference in the Request ast.Object, since we might require that to ignore any generic request attribute from the cache key. Let me get back to you on this next week. Meanwhile please do share if you have any pointers. Thanks!

rudrakhp avatar Apr 05 '24 21:04 rudrakhp

@rudrakhp just checking to see if you got a chance to explore the option of excluding certain request object params.

ashutosh-narkar avatar Apr 11 '24 17:04 ashutosh-narkar

@ashutosh-narkar was out last week, will raise an updated PR this week.

rudrakhp avatar Apr 17 '24 15:04 rudrakhp

This pull request has been automatically marked as stale because it has not had any activity in the last 30 days.

stale[bot] avatar May 17 '24 21:05 stale[bot]

@rudrakhp this would be a good one to get in the next release. Let us know if you need any help. Thanks.

ashutosh-narkar avatar May 23 '24 17:05 ashutosh-narkar

@ashutosh-narkar I just realised that request object was a pointer and it was getting modified as we modify the key, the downstream request will also not get these ignored headers. I have made a couple of new changes to address that, please do review. Thanks for the comments!

rudrakhp avatar May 26 '24 14:05 rudrakhp

Deploy Preview for openpolicyagent ready!

Name Link
Latest commit 54a583525f7957cc6686a54281746a7232643303
Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/6658a82ed49ad8000858d4b7
Deploy Preview https://deploy-preview-6675--openpolicyagent.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar May 26 '24 19:05 netlify[bot]