CSS / HTML / JS not updating XAMPP (local development)

CSS / HTML / JS not updating XAMPP (local development)

August 30, 2026 · Illustrated author avatarBy Stefan Bogdanescu
CSS / HTML / JS not updating XAMPP (local development)

Solving CSS/HTML/JS Caching Issues in XAMPP Local Development

Are you facing persistent CSS, HTML or JavaScript caching issues while developing your Magento 2 project locally using XAMPP? You’re not alone! This common problem can be quite frustrating, but fear not—it’s a straightforward fix once you know the right steps to take.

Understanding the Problem: Apache Caching in XAMPP

Before we dive into the solution, let’s clarify what’s happening behind the scenes. By default, XAMPP comes with Apache configured to cache certain files for performance optimization. This caching mechanism is great for production environments but can be a nuisance during local development where you need real-time updates.

The issue arises when Apache serves cached versions of your static assets (CSS, JS, HTML) instead of the freshly updated ones from your filesystem. Even after refreshing or clearing cache in your browser, XAMPP stubbornly insists on displaying the old content.

Disabling Apache Caching: The .htaccess Approach

You’re correct in thinking that disabling caching via an .htaccess file could be a solution. Apache provides powerful directives for managing caching behavior through this configuration file located in your project’s root directory.

To disable caching completely, add or modify the following lines to your .htaccess file:

<IfModule mod_expires.c>
    ExpiresByType text/html "now"
    ExpiresByType application/xhtml+xml "now"
    ExpiresByType image/x-icon "now"
    ExpiresByType image/gif "max"
    ExpiresByType image/jpeg "max"
    ExpiresByType application/json "now"

    # JavaScript
    ExpiresByType application/javascript "now"
</IfModule>

This code tells Apache to set the Expires header of various file types to now, effectively disabling caching for those assets. The mod_expires.c module must be enabled in your Apache configuration.

A More Granular Approach: Enabling Developer Mode

While the .htaccess solution is effective, it’s worth exploring another approach that offers more granular control over caching behavior—enabling developer mode in Magento 2.

To enable developer mode:

  1. Open app/etc/env.php
  2. Change the value of MAGE_MODE to 'developer'
return [
    'MAGE_MODE' => 'developer',
    #... rest of the config
];

Developer mode automatically sets the following configuration values for you:

  • Sets x-magento-init headers on static files to prevent browser caching
  • Enables varnish:flush command execution for clearing cache
  • Enables generation of production mode assets during deployment

Best Practices for Local Development in XAMPP

To ensure smooth local development without running into pesky caching issues:

  1. Always enable developer mode when working on your project locally.
  2. Set up a proper version control system like Git to track changes and facilitate collaboration.
  3. Familiarize yourself with Magento’s deployment workflow, which includes commands like setup:upgrade, static-content:deploy, and cache:flush.
  4. Learn how to use Xdebug effectively for debugging your PHP code in XAMPP.

Conclusion

In summary, solving CSS/HTML/JS caching issues in XAMPP local development comes down to disabling or configuring the right caching mechanisms. Whether you choose to modify the .htaccess file directly or rely on Magento’s developer mode settings, the key is understanding how Apache handles static assets and taking control of its caching behavior.

Remember that these solutions are specifically tailored for local development environments; in production, proper caching is essential for optimizing performance. Always ensure you have a robust deployment process in place to handle caching effectively when moving between stages.

For more detailed guides on Magento 2 development workflows and best practices, be sure to check out the comprehensive resources available at Laravel Company.

Magento 2 Catalog Cache Performance

Our network