プロジェクト

全般

プロフィール

Vote #79533

未完了

application.css imported by themes not covered by cache control versioning

Admin Redmine さんがほぼ2年前に追加. ほぼ2年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Themes_38
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
38
version_id:
0
issue_org_id:
29625
author_id:
363133
assigned_to_id:
0
comments:
4
status_id:
1
tracker_id:
1
plus1:
1
affected_version:
closed_on:
affected_version_id:
141
ステータス-->[New]

説明

The subject and #24617-12 pretty much says it all.

After an update, the old application.css still gets used by browsers' caches, with no means other than renaming the file and its import statements in the used theme to force cache invalidation.

Partial workaround:
public/themes//stylesheets/application.css

Change import statement
@import url(../../../stylesheets/application.css);

to some other name (e.g. application_v2.css)

Rename public/stylesheets/application.css to e.g. application_v2.css

Also apply the cache control hack in the mentioned ticket.

However, you can still never go back to application.css as browsers will still keep it cached forever. A fix is needed that makes the filename unique on every update, much like all other resources.
This may also affect other resources delivered by themes (e.g. images), so a best practice should be given for how to avoid that as well.


journals

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
+1

I think this information should be known more.

--------------------------------------------------------------------------------
> Change import statement
> @import url(../../../stylesheets/application.css);
>
> to some other name (e.g. application_v2.css)
>
> Rename public/stylesheets/application.css to e.g. application_v2.css
A "better" workaround is to append a ?version tag instead of renaming the file, that way you don't have to modify redmine internal files. The downside still being that you have to remember to update your theme everytime you upgrade redmine..

Example:
<pre>
@import url(../../../stylesheets/application.css?4.3.2);
</pre>

So I also modified the cache directive from https://www.redmine.org/projects/redmine/wiki/BrowserCaching#The-work-round-for-RedMine

I decided to stop caching any files which don't have the ?version tags. At least on redmine 4.2.3, the vast majority of the files have this tag. Only leaving out a few images which are loaded from application.css

<pre><code class="diff">
- # the regex logic: after either /javascripts/ or /stylesheets/ find the suffixes we want, followed by any quantity of numbers 0-9
+ # the regex logic: after either /javascripts/ or /stylesheets/ find the suffixes we want, followed by one or more numbers 0-9
# This works because the files we want to cache always appear after one of those 2 directories: but not the files we want to ignore
# /journals/edit/24174.js and /uploads.js?attachment_id=1&filename=my-file-to-upload.png
- location ~* {{REDMINE_RELATIVE_URL_ROOT}}(?<file>/(?:(?:plugin_assets/|themes/).+)?(?:javascripts|stylesheets|images|favicon)/.+(?:css|js|jpe?g|gif|ico|png|html)(\?[0-9]+)?$) {
+ location ~* {{REDMINE_RELATIVE_URL_ROOT}}(?<file>/(?:(?:plugin_assets/|themes/).+)?(?:javascripts|stylesheets|images|favicon)/.+(?:css|js|jpe?g|gif|ico|png|html)(\?[0-9]+)$) {
</code></pre>

--------------------------------------------------------------------------------


related_issues

relates,Closed,24617,Browser js/css cache remains after upgrade

Admin Redmine さんがほぼ2年前に更新

  • カテゴリThemes_38 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0