这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@inetol
Copy link
Member

@inetol inetol commented Jul 11, 2025

I've seen that by default Granian sets a Cache-Control header for 86400 seconds IF GRANIAN_STATIC_PATH_MOUNT is set. This option is not a hard requirement, but it's set because I found to be faster when serving the static files.

Another thing is that by removing GRANIAN_STATIC_PATH_MOUNT, the headers set by the application are present again in the static files, which was not the case before 🤦

Having the GRANIAN_STATIC_PATH_MOUNT set:
Screenshot From 2025-07-11 17-43-20

Without GRANIAN_STATIC_PATH_MOUNT:
Screenshot From 2025-07-11 17-43-48

Related #5004


Related with issue in searxng/searxng-docker#410 (comment)

I've seen that by default Granian sets a `Cache-Control` header for 1 day IF `GRANIAN_STATIC_PATH_MOUNT` is set. This option is not a hard requirement, but it's set because I found to be faster when serving the static files.

Another thing is that by removing `GRANIAN_STATIC_PATH_MOUNT`, the headers set by the application are present again in the static files, which was not the case before.

Related searxng#5004
@inetol
Copy link
Member Author

inetol commented Jul 18, 2025

If there are no objections I will merge this PR in a few hours

Copy link
Member

@return42 return42 left a comment

Choose a reason for hiding this comment

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

If there are no objections I will merge this PR in a few hours

Sorry for being such unresponsive .. LGTM, thanks for your deep analyses 👍

@inetol inetol merged commit b95a3e9 into searxng:master Jul 19, 2025
7 checks passed
@inetol inetol deleted the mod-granian-static2 branch July 19, 2025 08:18
inetol added a commit to searxng/searxng-docker that referenced this pull request Jul 19, 2025
* [fix] container: remove static hashing

Allows browser cache heuristics to properly work.

Related searxng/searxng#5006
Closes #409

* [fix] container: don't revalidate at every request

As Granian no longer handles static files directly, the whole process goes through Flask, which apart from being slow, is resource intensive, even to serve HTTP 304 responses.
@gi0baro
Copy link

gi0baro commented Jul 30, 2025

@inetol fyi, Granian 2.5.x allows to disable cache headers on static files.
If the headers thing was the only reason for this, re-enabling direct static files serving in Granian will for sure have better perf.

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.

3 participants