1

I am debugging a JavaScript problem and I am confused as to how the static files and versions work... I see the following in a stacktrace and can open this in a new tab:

https://example.com/static/version1577121673/vendors/ModuleVendor/adminhtml/en_US/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js

but I know this file to actually be as listed but without version1577121673 (I know because I've directly edited it with a couple of console.log commands):

https://example.com/static/vendors/ModuleVendor/adminhtml/en_US/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js

Where/how is it that the URL with version1577121673 is linked, mapped or otherwise to the actual file on the server?

1

It is an nginx/htaccess configuration.

For nginx it can be found in the nginx.conf.sample file at the root of your magento installation.(Or nginx.conf if you are already using nginx)

# Remove signature of the static files that is used to overcome the browser cache
    location ~ ^/static/version {
        rewrite ^/static/(version[^/]+/)?(.*)$ /static/$2 last;
    }

For apache the code can be found in the pub/static/.htaccess file

# Remove signature of the static files that is used to overcome the browser cache
    RewriteRule ^version.+?/(.+)$ $1 [L]

As you can see, both directives remove the version from the uri to be able to get the good file. The point of doing this is to make sure when you deploy your static files the browser is going to reload the file since its path has changed and won't load one of its cached file.

0

You can find this version here. /var/www/html/magento_directory/pub/static/deployed_version.txt. It'll change every time while you run the command.

0

Take a look at Magento 2 devDocs for Static content signing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.