Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I want to force reload CSS and JS on my sites (non-Magento 2), I usually just add a query string to the end of the URLs. For example: css/styles.css?v=1

I tried this in M2 by adding adding the above to my style files in my custom default_head_blocks.xml Although the style files are being loaded (I can click on the links in 'View Source' and it shows me the correct CSS file content) but the page isn't being styled.

Any idea why it's not working? Or, do you know how to force reload CSS / JS on the client side in M2?

share|improve this question

Magento 2 has this ability built-in called "Sign Static Files". It doesn't use the query string, but uses a generated subfolder starting with "version....", but basically the same idea. You can find it here... Stores > Configuration > Advanced > Developer > Static Files Settings > Sign Static Files

Here's more info on Using Static File Signatures.


Side note for anyone here using Magento 1... for Magento 1 I have used the Queryfier extension by Bubble Code and it does a great job (it uses the query string method).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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