Bug #91886

No automatic reload of changed static assets (JavaScript, css, images) in TYPO3 backend

Added by Sybille Peters 11 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2020-07-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When backend JavaScript files etc. change after a TYPO3 update, the following will not necessarily be enough to get them reloaded:

  • "Flush cache" in Maintenance module
  • relogin
  • Shift-reload (e.g. CTRL-SHIFT-r)

Instead, you have to flush entire browser cache to get them reloaded.

The backend files are not loaded with a hash, for example the URL for PageTreeToolbar.js is:

/sysext/backend/Resources/Public/JavaScript/PageTree/PageTreeToolbar.js?bust=b9abf8dc7cadbc94540d1578ff830fba67693967

The hash-value for bust does not change, when the file changes.

Reproduce:

  1. get latest 9.5 git branch
  2. perform all cleanup operations (composer install, "flush cache", relogin etc.)
  3. open Developer Tools: console
  4. load the page tree
  5. look for a JavaScript file (e.g. PageTreeToolbar.js)
  6. save the URL for this file as it was loaded

Now,

  1. install a patch or just make a small change to the file (e.g. add console.log to file PageTreeToolbar.js line 174)
  2. do all actions of 2 again, but do not flush entire browser cache
  3. load page tree
  4. look at JavaScript console
  5. save the URL for the JS file as it was loaded

Expected result

After flushing cache in Maintenance and relogin, the new JavaScript file should get used in the browser and you should see the log message.

Actual result.

The URL for PageTreeToolbar.js is the same before and after the change.

If it is not explicitly reloaded (e.g SHIFT-reload on this URL or flush entire browser cache), the old version will still be used.

After the change, the log message will not be shown.

Only after flushing entire browser cache or shift-reloading URL for PageTreeToolbar.js (e.g. http://t3coredev9/typo3/sysext/backend/Resources/Public/JavaScript/PageTree/PageTreeToolbar.js?bust=b9abf8dc7cadbc94540d1578ff830fba67693967)

System

  • TYPO3 9 (latest)
  • Apache webserver
  • mod_expires configuration as in default .htaccess from core

HTTP headers:

curl -I "http://t3coredev9/typo3/sysext/backend/Resources/Public/JavaScript/PageTree/PageTreeToolbar.js?bust=b9abf8dc7cadbc94540d1578ff830fba67693967" 

...
Date: Wed, 29 Jul 2020 08:28:42 GMT
Last-Modified: Wed, 29 Jul 2020 08:02:27 GMT
Cache-Control: max-age=31536000
Expires: Thu, 29 Jul 2021 08:28:42 GMT
...

Proposed solution

URL of static assets should change if file changes.

Impact

The (current) behaviour effectively means BE users must flush their browser cache after a TYPO3 update.


Related issues

Related to TYPO3 Core - Bug #89086: Third party extension requireJS modules are cached by browsers despite version updateClosedBenjamin Franzke2019-09-05

Actions
#1

Updated by Sybille Peters 5 months ago

  • Status changed from New to Closed

It seems that the bust parameter is changed, when the version changes, see https://forge.typo3.org/issues/89086

So in development, if you make changes to the JavaScript and the version does not change, you have to flush cache manually.

I think this is ok.

It might make sense to add information about bust parameter and caching behaviour to the docs, though, see https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/issues/1273

#2

Updated by Sybille Peters 5 months ago

  • Related to Bug #89086: Third party extension requireJS modules are cached by browsers despite version update added

Also available in: Atom PDF