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

JS/CSS and other assets should be linked from the generated HTML having their last mod time #3401

Closed
thehowl opened this issue Jan 20, 2018 · 5 comments
Labels
issue/stale type/enhancement An improvement of existing functionality

Comments

@thehowl
Copy link
Contributor

thehowl commented Jan 20, 2018

Currently, assets are linked directly from the generated HTML, and they are cached by the browser, even more so after #3376. To avoid the website breaking when a Gitea instance is updated, we should probably add at the end of links to JS/CSS and assets a timestamp or a MD5/SHA1 hash of the file, in order to help tell the browser when it has been updated (in spite of the Expires on the request); for instance, like this: /vendor/assets/octicons/octicons.min.css?1516470750 or /vendor/assets/octicons/octicons.min.css?34c741261b8c1fe08cde34db14773785

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Jan 20, 2018
@techknowlogick
Copy link
Member

techknowlogick commented Jan 21, 2018

Instead of hashing each file and saving that info in the application to remember, what could be done is to use the git hash of the gitea build (as in /vendor/assets/octicons/octicons.min.css?34c74126, where 34c74126 would be appended to all assets). To stop privacy leaks (as not everyone wants that hash to be out in the open) the hash could be something like a sha1 of the startup time of gitea (hopefully people aren't rebooting their gitea instance too often). Or a combination of both (if people are ok with showing the hash that their instance is on, as it is an option in the config, then use that as it would persist across gitea reboots, but fallback to a sha1 of startup time).

@thehowl
Copy link
Contributor Author

thehowl commented Jan 21, 2018

what could be done is to use the git hash of the gitea build

Thought of that, but if an user changed the file by placing it in the custom/ folder, then the cache wouldn't be invalidated.

the hash could be something like a sha1 of the startup time of gitea (hopefully people aren't rebooting their gitea instance too often)

I tend to agree with this much more.

@lafriks
Copy link
Member

lafriks commented Jan 21, 2018

I would still reather see it to be hash of the file

@stale
Copy link

stale bot commented Feb 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Feb 8, 2019
@stale
Copy link

stale bot commented Feb 22, 2019

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Feb 22, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/stale type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants