Magento provides a feature to invalidate the browser cache for static content. Magento adds a deployment version number into the URL of static files.
To deploy static content we have to run setup:static-content:deploy
command, this command auto change the deployment version in pub/static/deployed_version.txt
, After this deployment url of static files auto change and forces the browser to load the new version of files.
If the url deployment version is not matched with the current deployment version
which exists in pub/static/deployed_version.txt
then it throws 404 errors
for those static files.
Url with deployment version:
1 |
https://manishmittal.com/pub/static/version4343544434/frontend/Magento/luma/en_US/images/email_logo.svg |
Magento recommends keeping this feature, preventing it from serving up old files or cached files. By default this feature is enabled in Magento.
In this article sharing 3 methods to disable it or remove deployment version number from url.
First Method: Using Magento admin,
Magento have configuration to enable/disable
this feature, here you go to find this configuration:
Stores > Configuration > Advanced > Developer > Static Files Settings
To disable it just change the value to No.
Flush Magento cache, bin/magento cache:flush
Second Method: Using command line,
Magento provides commands to check the value of static content signing and to enable/ disable it.
To check the status of content signing:
bin/magento config:show dev/static/sign
To enable/ disable, run below command:
bin/magento config:set dev/static/sign <value>
Here <value> =1 Enable, <value>=0 Disable
Flush Magento cache, bin/magento cache:flush
Third Method: Using Database,
In this method, you can directly run below shared DB query in database:
insert into core_config_data (config_id, scope, scope_id, path, value) values (null, 'default', 0, 'dev/static/sign', 0);
If it already exists in table then just run update query:
Update core_config_data set value=0 where path = "dev/static/sign"
Flush Magento cache, bin/magento cache:flush