-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Use separate asset path for different build #18348
Conversation
Removal of |
We had better have a special prefix, otherwise it's difficult to grep or proxy requests. ps: I updated the original comment to describe it clearly: |
I think in any case, we should retain the |
I do not want to use And |
why not use |
It's impossible now. Using
|
I too prefer hash in the filename. I think it can be made to work at least for the dynamically loaded webpack assets which allow to define
I don't follow. We've worked so hard to get everything under a common |
Any top level path you add means we have to restrict another username and we break every installation that is already using that username. Line 570 in 67d7388
I think you should use /assets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any top level path means that path must become a restricted username.
Either use /assets or a subdirectory of it - or add to
Line 570 in 67d7388
var ( |
My very strong preference is that we don't add more restricted usernames therefore I strongly recommend that you use /assets or change our URL structure so we can avoid this in future.
Maybe we do not need to restrict any top-level names any more. For internal usage, the char // AlphaDashDotPattern characters prohibited in a user name (anything except A-Za-z0-9_.-)
AlphaDashDotPattern = regexp.MustCompile(`[^\w-\.]`)
// used by IsUsableRepoName and IsUsableUserName So, what about using: |
There are a lot of legacy files (for example,
Please vote:
|
I think we should just copy GH in this regard, |
So, could we vote in these 3 options to move on? And we can continue to improve in future. |
Ah well, seems like everyone and their cat have a say on this, so I will just give my vote before this explodes. I think the "Use As from my understanding the Btw, development files should most likely also have a time-stamp instead PS: Just vote, or bring your own PR to do the optimal |
Thank you Gusted! Since Gitea PR requires 2 approvals to get merged, I hope I can find one more voter(reviewer) to continue the work. |
I agree to renaming |
Sorry but I'm also against hash in directory name |
OK, then we need some new solutions. Since most do not like this PR, so we do not need to work on it. I still can not understand why it should be |
Alternate solution that alters only the filenames: #18632, still WIP. |
There are a lot of people complaining the cache problem again. I have received at least 10 reports. If this PR can be merged early, there will be no such problem any more and can be more friendly to end users. This PR is very clear and simple, it's very easy to be refactored to other solutions (eg: dynamic asset names) later. I still can not understand why the bug should be kept and make people complaining. |
Development & Production version should enable cache when the asset is the same and disable cache when the asset is not the same. Since cache could be disabled from web browser. It seems it's unnecessary to diff Development & Production versions. A directory prefix will make all the cache disabled even if the image is not changed between two updates. i.e. when a public site upgrade from 1.16.1 to 1.16.2, all the assets cache will be disabled especially monoca editors, it will load a bit time. But that could be avoid in an ideal situation. |
How much bandwidth will it waste to reload all assets? Are these assets larger than the Gitea rendered pages during daily use? Does the "a bit time" make users unhappy? |
I don't think users cannot bear that, but if we can have an ideal method, that's better. |
Then, do you mean that people prefer to bear bugs (UI not working) instead of the only once "a bit time" delay? Especially the delay only occurs for the first time after upgrade, which is pretty low frequency. |
Background
Gitea used to use
/assets/js/index.js?v={{MD5 AppVer}}
to access static files. This mechanism has some problems:?v=...
query string./assets/vendor/plugins/codemirror/addon/mode/loadmode.js
and others.Plan
This PR introduces a dynamic path for web URL:
/public~dynamic
:/public~dynamic/js/index.js
/public~17e7b119ec1
(versioned with timestamp):/public~17e7b119ec1/js/index.js
It's possible to help #18347 and other problems.
There are still more work to do (there are many hard-coded
/assets
strings in code). If this PR is fine, I can continue to work on it.More details:
Why not using
index-{ver}.js
orindex.{ver}.js
?There are a lot of legacy files (for example,
/plugins/codemirror/addon/mode/loadmode.js
, they are not controlled by webpack). Using hash in filenames could be done in future, but not now.Why not using the
/assets
path?The
assets
is not a good name indeed. Why theGITEA_CUSTOM/public
was still calledpublic
but used as/assets
? We should either call all of themassets
(rename public) ORpublic
(as comment above with~
) OR/assets/public-{ver}
. I do not like keeping getting new names for one concept.What about reserved path name?
We can use
~
which is not a valid user/repo name, then we do not need restrict any names anymore.What about existing custom templates?
We provide template variable and JS variable,
AssetUrlPrefix
. It's totally transparent to all users.If the writer of the custom templates used hard-coded
/assets/
, then they should update. I believe such usage is not recommended, they should use{{AssetUrlPrefix}}
Possible solutions
Please vote:
/public~{ver}/
forGITEA_CUSTOM/public
/assets~{ver}/
and renameGITEA_CUSTOM/public
toGITEA_CUSTOM/assets
/assets/public-{ver}/
forGITEA_CUSTOM/public