Skip to content

Commit b9d7b75

Browse files
committed
✨ Add option to disable cache buster for PreloadAsset
1 parent 31310ae commit b9d7b75

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

Configuration/Settings.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Carbon:
3030
Default:
3131
Package: SitePackage
3232
CacheBuster: true
33+
DisableCacheBusterForPreloadAsset: true
3334
ConditionPrototype: null
3435
Path:
3536
Inline:

Resources/Private/Fusion/External/Collection.fusion

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ prototype(Carbon.IncludeAssets:Collection) < prototype(Neos.Fusion:Component) {
66
collection = ${[]}
77
assetPackage = null
88
cacheBuster = ${Configuration.setting('Carbon.IncludeAssets.Default.CacheBuster')}
9+
disableCacheBusterForPreloadAsset = ${Configuration.setting('Carbon.IncludeAssets.Default.DisableCacheBusterForPreloadAsset')}
910
paths = ${Configuration.setting('Carbon.IncludeAssets.Default.Path')}
1011

1112
renderer = afx`
1213
<Neos.Fusion:Collection @if.render={props.assetPackage} collection={props.collection} @children='itemRenderer'>
13-
<Carbon.IncludeAssets:File file={item} assetPackage={props.assetPackage} cacheBuster={props.cacheBuster} paths={props.paths} />
14+
<Carbon.IncludeAssets:File
15+
file={item}
16+
assetPackage={props.assetPackage}
17+
cacheBuster={props.cacheBuster}
18+
disableCacheBusterForPreloadAsset={props.disableCacheBusterForPreloadAsset}
19+
paths={props.paths}
20+
/>
1421
</Neos.Fusion:Collection>
1522
`
1623
}

Resources/Private/Fusion/External/File.fusion

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) {
66
file = null
77
assetPackage = ${node.context.currentSite.siteResourcesPackageKey}
88
cacheBuster = ${Configuration.setting('Carbon.IncludeAssets.Default.CacheBuster')}
9+
disableCacheBusterForPreloadAsset = ${Configuration.setting('Carbon.IncludeAssets.Default.DisableCacheBusterForPreloadAsset')}
910
assetPath = null
1011

1112
// This is a internal variable, please use `assetPath` for an single file
@@ -17,6 +18,7 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) {
1718
file = ${props.file}
1819
assetPackage = ${props.assetPackage}
1920
cacheBuster = ${props.cacheBuster}
21+
disableCacheBusterForPreloadAsset = ${props.disableCacheBusterForPreloadAsset}
2022
assetPath = ${props.assetPath ? props.assetPath : props.paths[this.assetKey][this.type]}
2123

2224
fileObject = ${Carbon.IncludeAssets.parseFilename(props.file)}
@@ -50,7 +52,7 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) {
5052
<Carbon.IncludeAssets:Internal.Tag.JS path={props.path} fileObject={props.fileObject} cacheBuster={props.cacheBuster} />
5153
`
5254
preload = afx`
53-
<Carbon.IncludeAssets:Internal.Tag.ResourceHint rel='preload' path={props.path} fileObject={props.fileObject} cacheBuster={props.cacheBuster} />
55+
<Carbon.IncludeAssets:Internal.Tag.ResourceHint rel='preload' path={props.path} fileObject={props.fileObject} cacheBuster={props.cacheBuster} disableCacheBusterForPreloadAsset={props.disableCacheBusterForPreloadAsset} />
5456
`
5557
modulePreload = afx`
5658
<Carbon.IncludeAssets:Internal.Tag.ResourceHint rel='modulepreload' path={props.path} fileObject={props.fileObject} cacheBuster={props.cacheBuster} />

Resources/Private/Fusion/Internal/Package.fusion

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ prototype(Carbon.IncludeAssets:Internal.Package) < prototype(Neos.Fusion:Compone
2424
}
2525
assetPackage = ${props.mergedConfig.Package == 'SitePackage' ? node.context.currentSite.siteResourcesPackageKey : props.mergedConfig.Package}
2626
cacheBuster = ${props.mergedConfig.CacheBuster}
27+
disableCacheBusterForPreloadAsset = ${props.mergedConfig.DisableCacheBusterForPreloadAsset}
2728
paths = ${props.mergedConfig.Path}
2829
collection = Neos.Fusion:RawCollection {
2930
collection = ${['General', 'Backend', 'Live']}
@@ -36,7 +37,13 @@ prototype(Carbon.IncludeAssets:Internal.Package) < prototype(Neos.Fusion:Compone
3637
}
3738

3839
renderer = afx`
39-
<Carbon.IncludeAssets:Collection assetPackage={props.assetPackage} cacheBuster={props.cacheBuster} collection={props.collection} paths={props.paths} />
40+
<Carbon.IncludeAssets:Collection
41+
assetPackage={props.assetPackage}
42+
cacheBuster={props.cacheBuster}
43+
disableCacheBusterForPreloadAsset={props.disableCacheBusterForPreloadAsset}
44+
collection={props.collection}
45+
paths={props.paths}
46+
/>
4047
`
4148
}
4249
}

Resources/Private/Fusion/Internal/Tag.fusion

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ prototype(Carbon.IncludeAssets:Internal.Tag) < prototype(Neos.Fusion:Component)
3131
prototype(Carbon.IncludeAssets:Internal.Tag.ResourceHint) < prototype(Carbon.IncludeAssets:Internal.Tag) {
3232
async = false
3333
rel = null
34+
disableCacheBusterForPreloadAsset = true
35+
[email protected] = ${this.disableCacheBusterForPreloadAsset && this.fileObject && this.fileObject.type == 'PRELOADASSET' ? false : value}
3436
@if.hasRel = ${this.rel}
3537
renderer.resourceHint = ${'<link rel="' + props.rel + '" href="' + this.uri + '"' + props.attributes +' />'}
3638
}

0 commit comments

Comments
 (0)