-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[6.1] Add "nocache" as version option to webasset manager #46379
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
base: 6.1-dev
Are you sure you want to change the base?
Conversation
|
Just wondering if this is not already solved by passing a random string as version option? |
That's not possible in a json file. |
|
Sure, but I would then probably use the existing version attribute and support there a "nocache" value instead of adding a new flag. But this is just personal preference. |
|
We already have this feature. Enable Debug and you will get version refresh for every It is also possible just call |
I'm not sure to understand you? I set the existing "version" attribute to "nocache" similar to "auto" and not adda new attribute? |
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
I want to do something different, I don't want to set it manually on each layout I'm using it and and want to have this persistent if I need to by path cache for what ever reason. (3rd party services for example).
|
|
Hm, I not very understand your use case. If you want to have some "custom generated" version only for specific asset and do not want to use setOption() in each layout then can also create a custom class: {
"name": "myasset",
"type": "script",
"class": "MyAssetItem",
"namespace": "Foo\\Bar"
"uri": "....myasset.js"
},class MyAssetItem extends WebAssetItem
{
public function __construct(
string $name,
?string $uri = null,
array $options = [],
array $attributes = [],
array $dependencies = []
) {
parent::__construct($name, $uri, $options, $attributes, $dependencies);
$this->version = ComponentHelper::getParams('com_mycomponent')->get('myMediaVersion', '');
}
}Similar to joomla-cms/build/media_source/system/joomla.asset.json Lines 8 to 13 in 7bd2c5b
|
|
I am not against it, if people want it then we can add. |
I want to make developer life easier, I don't want to create a new WebAsset if I just don't want no caching for exactly one script for a temporary time. Of course we can add an additional webassetitem in core that does this, but that sounds a bit overengineered compared to the the 2 lines of code change. |
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
|
When I need it I usually just enable debug and disable debug plugin to hide the debug bar. With |
|
I have tested this item ✅ successfully on 53614f1 So I'm in favour of this change. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46379. |
|
obviously this needs documentation please |
|
Of course, we will see if I can do it or someone else needs to create it. |
Summary of Changes
Add the magic value "nocache" similar to "auto" to the
joomla.asset.jsonrenderer for scripts and styles.This allows to add a js and css file already to the asset file while developing without struggling with all the possible cache layers.
Additional, it's possible that you need a cache buster for resources which are not under your control and changes frequently or are dynamically generated with a broken cache header.
Testing Instructions
Modify the
versionattribute in your joomla.asset.json to "nocache".Actual result BEFORE applying this Pull Request
Expected result AFTER applying this Pull Request
Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org: Will be added when excepted
No documentation changes for manual.joomla.org needed