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

Caching #480

Merged
merged 3 commits into from
Mar 16, 2019
Merged

Caching #480

merged 3 commits into from
Mar 16, 2019

Conversation

trinity-1686a
Copy link
Contributor

@trinity-1686a trinity-1686a commented Mar 15, 2019

Try to cache static resources.
Static non media file's timestamps are hashed at compile tome so that modifying them invalidate old cache.
For some reason, plume-front.wasm isn't loaded from cache, even if it contains the right headers.
I changed nothing and now it is? I guess I'm ok with it
I'll look into adding Etag support too
All response made from templates and not containing a form are now Etag-cached

@trinity-1686a trinity-1686a added C: Enhancement New feature or request S: Incomplete This PR is not complete yet A: Backend Code running on the server labels Mar 15, 2019
@elegaanz elegaanz self-requested a review March 15, 2019 21:05
Copy link
Contributor

@igalic igalic left a comment

Choose a reason for hiding this comment

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

👀

build.rs Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 16, 2019

Codecov Report

Merging #480 into master will decrease coverage by 0.31%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master     #480      +/-   ##
==========================================
- Coverage   27.13%   26.82%   -0.32%     
==========================================
  Files          64       64              
  Lines        7337     7423      +86     
==========================================
  Hits         1991     1991              
- Misses       5346     5432      +86

build.rs Outdated
@@ -1,8 +1,39 @@
extern crate plume_common;
Copy link
Member

Choose a reason for hiding this comment

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

You should probably remove it from Cargo.toml too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I totally forgot about that

Copy link
Contributor

@igalic igalic left a comment

Choose a reason for hiding this comment

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

👍

build.rs Show resolved Hide resolved
@trinity-1686a trinity-1686a added S: Ready for review This PR is ready to be reviewed and removed S: Incomplete This PR is not complete yet labels Mar 16, 2019
impl<'r> Responder<'r> for Ructe {
fn respond_to(self, r: &Request) -> response::Result<'r> {
//if method is not Get or page contain a form, no caching
if r.method() != Method::Get || self.0.windows(6).any(|w| w == b"<form ") {
Copy link
Member

Choose a reason for hiding this comment

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

Probably obvious, but why do we disable caching on pages with a form?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the page contain a form, the csrf token will be cached, and may no longer match user's cookies. As these tokens are added later by a fairing, there is no way to detect the page changed here. The other solution could be to allow caching of page and for rocket_csrf to remove ETag when appropriate

Copy link
Member

@elegaanz elegaanz left a comment

Choose a reason for hiding this comment

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

👍 Thanks!

@trinity-1686a trinity-1686a merged commit a2b2e37 into master Mar 16, 2019
@trinity-1686a trinity-1686a deleted the cache branch March 16, 2019 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: Backend Code running on the server C: Enhancement New feature or request S: Ready for review This PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants