3

I'm developing a theme right now, and some of my image assets are 404'ing because they are trying to load from a strange directory in /pub/static.

enter image description here

When I ls in /pub/static, there is no /versionXYZ/ directory there at all, only .htaccess, _requirejs folder, and frontend folder, as expected.

I've done bin/magento cache:flush and grunt exec and grunt less already, and it still is referencing this weird URL.

Where does that reference come from?

1 Answer 1

3

The version### folder is a result of a developer setting: Admin > Stores > Configuration > Advanced > Developer > Static Files Settings > Sign Static Files

This setting has been there since Magento 2.0 release, but was disabled by default until 2.1.3. It's now enabled by default.

The setting adds a release version to the path of all static files (within pub/static/*). This is a cachebuster: It ensures that any changes to files take effect immediately for all users, even if browser caching or CDN is in effect. As you've noticed, it can be used even in developer mode.

The requests are routed to the equivalent path without the version### folder via pub/static/.htaccess.

Make sure that htaccess file is present, or if you are using nginx, that your server configuration has an equivalent redirect rule. Or, for development, you can simply disable the setting. (Not recommended for production.)

1
  • As a note, if this happens and you cannot get to your backend to fix it, add a core_config_data entry with the path dev/static/sign and value of 0, then flush your cache.
    – Morgon
    Feb 15, 2017 at 16:25

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.