Skip to content

Proxy server could cache http response when it is not private - #20897

Merged
rullzer merged 3 commits into
masterfrom
bugfix/httpcache
May 13, 2020
Merged

Proxy server could cache http response when it is not private#20897
rullzer merged 3 commits into
masterfrom
bugfix/httpcache

Conversation

@kklem0

Copy link
Copy Markdown
Contributor

Proxy server could cache http response when it is not private
Need this for nextcloud/mail#3071

@kklem0

Copy link
Copy Markdown
ContributorAuthor

See https://www.nginx.com/blog/nginx-caching-guide/

How Does NGINX Determine Whether or Not to Cache Something?

By default, NGINX respects the Cache-Control headers from origin servers. It does not cache responses with Cache-Control set to Private, No-Cache, or No-Store or with Set-Cookie in the response header. NGINX only caches GET and HEAD client requests. You can override these defaults as described in the answers below.

@kklem0

Copy link
Copy Markdown
ContributorAuthor

Note that there are situations when proxy caching make sense like avatar, so I'm not 100% sure of this PR if we should just make everything only cache by browser or if we wanna have another function for private caching.

Signed-off-by: Clement Wong <git@clement.hk>
@kklem0
kklem0force-pushed the bugfix/httpcache branch from 354f54f to 401210dCompareMay 10, 2020 09:24
@rullzer

Copy link
Copy Markdown
Member

right yes. This was on my list for ages.

So avatars is not a good example. But the endpoints that server bundle js or compiled scss are public of course.

Would you mind adding an optional argument 'public' (set to false by default)?

@rullzerrullzer self-assigned this May 10, 2020
@rullzerrullzer added the 2. developing Work in progress label May 10, 2020
Signed-off-by: Clement Wong <git@clement.hk>
@kklem0
kklem0force-pushed the bugfix/httpcache branch from 0cffd89 to e9be3a9CompareMay 10, 2020 18:24
@kklem0

Copy link
Copy Markdown
ContributorAuthor

Don't think the failed tests are related.

@ChristophWurst

Copy link
Copy Markdown
Member

Don't think the failed tests are related.

https://drone.nextcloud.com/nextcloud/server/28807/10/4

Bildschirmfoto von 2020-05-12 10-31-50

That one is :)

@ChristophWurst

Copy link
Copy Markdown
Member

@rullzer backport?

@kklem0

Copy link
Copy Markdown
ContributorAuthor

Don't think the failed tests are related.

https://drone.nextcloud.com/nextcloud/server/28807/10/4

Bildschirmfoto von 2020-05-12 10-31-50

That one is :)

Missed that, and was looking at the wrong test file.
Thanks!

Signed-off-by: Clement Wong <git@clement.hk>
@kklem0
kklem0force-pushed the bugfix/httpcache branch from 96ce64d to 979dd1bCompareMay 12, 2020 09:50
@kklem0

Copy link
Copy Markdown
ContributorAuthor

@rullzer backport?

Would be cool if it can be backported as I need to use it with the mail app and I'm hoping to ditch my custom code in it.

@rullzer

Copy link
Copy Markdown
Member

I'm not 100% sure about the backport. Since it changes the API.

Of course it just adds a parameter which php will happily swallow....

@ChristophWurst

Copy link
Copy Markdown
Member

I'm not 100% sure about the backport. Since it changes the API.

If we don't want to change the API we should backport the default to private caching IMO.

@kklem0

Copy link
Copy Markdown
ContributorAuthor

Shall I default to $public = true for now?

@rullzer

Copy link
Copy Markdown
Member

Nah leave it to false I'd say. Like in the worst case you don't cache something in the proxy that could be cached in theory.

@rullzer
rullzer merged commit 4fbea31 into masterMay 13, 2020
@rullzer
rullzer deleted the bugfix/httpcache branch May 13, 2020 06:27
@ChristophWurst

Copy link
Copy Markdown
Member

/backport to stable19

@ChristophWurst

Copy link
Copy Markdown
Member

/backport to stable18

@ChristophWurst

Copy link
Copy Markdown
Member

/backport to stable17

@backportbot-nextcloud

Copy link
Copy Markdown

The backport to stable18 failed. Please do this backport manually.

@backportbot-nextcloud

Copy link
Copy Markdown

The backport to stable17 failed. Please do this backport manually.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developingWork in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@kklem0@rullzer@ChristophWurst