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

fix: #1301 - Apply compression before caching #2393

Merged
merged 2 commits into from
Oct 1, 2023
Merged

Conversation

provinzkraut
Copy link
Member

Fix #1301 by introducing a moving caching to a hybrid approach that records outgoing ASGI messages within a middleware and hydrates them within the route when responding to a request.

There are some additional benefits to this approach:

  • Improved performance and reduced size of the stored responses by switching from pickle to MessagePack and storing already compressed responses and only compressing them once
  • Reduced overhead because the middleware can be applied ahead of time to only those routes that have caching enabled instead of checking each request
  • Every response can now be cached without issues; Previously only those that could be pickled could be cached

@provinzkraut provinzkraut requested review from a team as code owners October 1, 2023 11:17
Signed-off-by: Janek Nouvertné <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Oct 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@github-actions
Copy link

github-actions bot commented Oct 1, 2023

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/2393

Copy link
Member

@cofin cofin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cofin cofin merged commit 61b71d4 into main Oct 1, 2023
18 checks passed
@cofin cofin deleted the caching-middleware branch October 1, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Compression is applied after request caching
2 participants