skip to Main Content

I’ve tried to install Magento 2 locally using XAMPP. This works fine, except for the fact that when I alter my CSS, HTML or JS, XAMPP won’t get the updated files. It just takes the file I initially created with it’s content, but not the updated version.

I think this has something to do with caching of Apache itself? I read something about disable cache using .htaccess (http://httpd.apache.org/docs/2.0/mod/mod_cache.html) but I can’t figure out how to implement this.

Anyone knows how I can fix this?

Flushing cache doesn’t work. Deploy static content may work, but I don’t want to do that every time I make one minor change in the CSS (when I worked remotely, I did not have to do that either)

I think this problem is not Magento related, but rather something with XAMPP (probably Apache).

I have developer mode enabled.

3

Answers


  1. Press Ctrl-F5 to hard refresh the page (to not use Browser’s cache).

    If you still see the previous pages or changes, then Apache has
    mod_cache caching them, or PHP has its opcode cache settings set to
    not refresh changes for X amount of time.

    Taken from Xampp and Ampps don't reload files when changed

    If mod_cache that is causing the problem then this might help you implement the fix How to disable cache of Apache?

    Login or Signup to reply.
  2. This is not a caching issue, but rather the deploy mode you’re using.

    You are probably in default mode, in which case you will have to deploy static content every time, however you can switch to developer mode.

    https://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-mode.html

    This will stop magento having the need to generate the static content as it’s done on the fly via the use of symlinks etc.

    bin/magento deploy:mode:set developer
    

    Or alternatively you can manually set this inside

    app/etc/env.php
    

    If developer mode isn’t working it’s more than likely down to permissions etc

    Delete all files inside pub/static apart from the htaccess file, and make sure it’s writable

    Login or Signup to reply.
  3. In developer mode, M2 does not generate static files. It should create symlinks to them from the various modules. If you however have ran setup:static-content:deploy and have those files in place, it won’t update them. Try to delete only those files inside pub/static folder on which you’ve worked and see if Magento links to them. If you delete all contents of pub/static/ folder, pages will take very long to load in browser.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search