Skip to content

Gitea should set Cache-Control: public (or unset) on raw files in public repositories so reverse proxies can cache properly. #21391

Closed
@ledlamp

Description

@ledlamp

Description

So it appears that Gitea always sets Cache-Control: private, max-age=300 on raw files, even if the asset is in a public repository and ought to be cachable by a reverse proxy.

This means that if you want to cache gitea right now, you have to override this, but then you'll expose files in private repositories since the proxy can't tell the difference.

It also appears that Gitea disables caching on HTML renders (no-store), which makes sense, but it might be a good idea to allow caching of those for unauthenticated visitors, since some views may not change frequently, but could have heavy traffic from unauthenticated visitors (think wikis and readmes with embedded images, etc).

Also, why does Gitea always set a cookie, even if you're not logged in? This is also problematic for caching; Cloudflare won't cache any response with a cookie for example. And since it appears the same i_like_gitea cookie is used for both guest sessions and logged in users, there is no way for a custom reverse proxy to tell the difference between visitors and logged-in users.

To the eyes of a reverse proxy, with these two issues, everyone is logged in, and nothing is cacheable!

Gitea Version

1.17.2, 1.18.0+dev-518-ga813c9d8f

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

N/A; checked response headers of raw file responses on gitea.moe and try.gitea.io.

Database

SQLite

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementAn improvement of existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions