Bug #89086

Third party extension requireJS modules are cached by browsers despite version update

Added by Benjamin Franzke 3 months ago. Updated 3 months ago.

Status:
Resolved
Priority:
Should have
Category:
Backend JavaScript
Start date:
2019-09-05
Due date:
% Done:

100%

TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

An Extension that contains requireJS modules in Resources/Public/JavaScript and includes a module in the backend using

    $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/ExtensionName/JavascriptModule');

can not update the JavascriptModule on extension updates, as the TYPO3 PageRenderer calculates a cache busting hash (for all requireJS modules)
from the current TYPO3_version and project path. Third party extension version are not taken into account.

That means a cache bust parameter, e.g "abcdefghijklmnopqrstuvwxyz1234567890abcdef" would be applies to the url:

/typo3conf/ext/extension_name/Resources/Public/JavaScript/JavascriptModule.js?bust=abcdefghijklmnopqrstuvwxyz1234567890abcdef

…but that hash is not changed when the Extension Version changes.

Note: For performance reasons only the extension version number should be taken into account. (File modification times would only be important for development scenarios where a separate development cache parameter override is available).

Associated revisions

Revision 8f7ccb3d (diff)
Added by Benjamin Franzke 3 months ago

[BUGFIX] Hash extension versions into requireJS bust parameter

When a third party extension that contains a requireJS backend module is
updated, the cache bust parameter needs to be updated as well, otherwise
browsers would not download the updated asset.

We will now include all extensions that contain requireJS modules into the
requireJS bust parameter hash calculation (by extension name and version).
That means an extension update of these extensions will trigger a new
bust parameter.

This has the slight drawback that the requireJS bust parameter will need
to be re-calculated after every extension update of such extensions, but
that's actually limited to extensions that provide requireJS modules, and
better than no asset updates at all.

This patch uses the PackageManager instead of ExtensionManagementUtility
to get access to the package version using the PackageInterface. Having
the full package array available we can also drop the
GeneralUtility::getFileAbsFilename('EXT:…') indirection which ends up
calling PackageManager anyway (only with added string parsing overhead).

Releases: master, 9.5
Resolves: #89086
Change-Id: Id183c935aad60a38231eb1b39aae5baed269f8ce
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61625
Tested-by: TYPO3com <>
Tested-by: Frank Nägler <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Frank Nägler <>
Reviewed-by: Andreas Fernandez <>

Revision 79c98351 (diff)
Added by Benjamin Franzke 3 months ago

[BUGFIX] Hash extension versions into requireJS bust parameter

When a third party extension that contains a requireJS backend module is
updated, the cache bust parameter needs to be updated as well, otherwise
browsers would not download the updated asset.

We will now include all extensions that contain requireJS modules into the
requireJS bust parameter hash calculation (by extension name and version).
That means an extension update of these extensions will trigger a new
bust parameter.

This has the slight drawback that the requireJS bust parameter will need
to be re-calculated after every extension update of such extensions, but
that's actually limited to extensions that provide requireJS modules, and
better than no asset updates at all.

This patch uses the PackageManager instead of ExtensionManagementUtility
to get access to the package version using the PackageInterface. Having
the full package array available we can also drop the
GeneralUtility::getFileAbsFilename('EXT:…') indirection which ends up
calling PackageManager anyway (only with added string parsing overhead).

Releases: master, 9.5
Resolves: #89086
Change-Id: Id183c935aad60a38231eb1b39aae5baed269f8ce
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61625
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61635

History

#1 Updated by Gerrit Code Review 3 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61625

#2 Updated by Gerrit Code Review 3 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61625

#3 Updated by Gerrit Code Review 3 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61635

#4 Updated by Benjamin Franzke 3 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF