Magento Multi language store with varnish

Magento Multi language store with varnish

September 22, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Multi language store with varnish

Optimizing Magento Multi-Language Stores with Varnish Caching

Running an e-commerce platform like Magento often requires balancing performance and functionality. When you’re managing multiple language sites, caching becomes even more critical to ensure fast loading times for your customers worldwide.

Understanding Magento Multilanguage Functionality

Magento’s out-of-the-box multi-language support is robust, allowing you to create separate store views for each language needed. However, the default setup doesn’t take full advantage of caching for improved speed.

By default, Magento uses a database-based cache that stores information in a relational database table. Although this provides the flexibility of storing complex data structures, it can be relatively slow compared to other storage options like Redis or Memcached.

Configuring Varnish for Multilanguage Stores

Varnish is an HTTP accelerator designed to increase website performance by caching frequently accessed pages. To use Varnish effectively with a Magento multi-language store, you’ll need to configure it properly:

  1. Install and Set Up Varnish: Install the latest stable version of Varnish on your server following the official documentation.

  2. Configure the VCL (Varnish Configuration Language) File: The vcl.conf file is where you define how Varnish interacts with clients, servers, and backend application (in this case, Magento).

  3. Configure Cookies for Language Selection: To create cache entries based on cookies (which typically store language selection), modify the vcl_recv function in your vcl.conf file:

sub vcl_recv {
    if (req.http.cookie ~ "mage-multidirectional-redirect=") {
        set req.backend = hit_for_pass;
        return (pass);
    }

    # Store the cookies for backend requests.
    if (req.method != "GET" && req.method != "HEAD") {
        return (pass);
    }

    # Remove all cookies so that store views are not created on the basis of a cookie.
    unset req.http.cookie;

    return (hash);  # Store in cache
}
  1. Configure Backend Host: Specify your Magento backend host using vcl_backend function:
sub vcl_backend {
    declare default;
    if (req.backend_hits > 0 && req.url ~ "\/(media|static)\/") {  # cache media and static files
        return (hit_for_pass);
    }
    return(default);
}

Serving Cached Pages for Different Languages

With this configuration, Varnish will serve cached pages based on the requested URL and query parameters. It won’t cache pages with different cookies or store views.

For example, www.example.com/en/ products and www.example.com/es/products are considered two separate URLs by Varnish, allowing it to cache each page independently without considering language-specific cookies.

Monitoring and Fine-Tuning Performance

To ensure optimal performance:

  • Monitor your Magento stores using tools like New Relic or Blackfire.
  • Regularly analyze cache statistics in the Varnish admin interface.
  • Configure your server’s memory settings to handle increased traffic effectively.
  • Consider using a CDN for even better global performance.

Conclusion: Maximizing Performance with Intelligent Caching

Combining Magento’s multi-language capabilities with Varnish’s caching power enables you to deliver fast, optimized experiences for customers across multiple language stores. Proper configuration, as outlined in this post, ensures that each store view benefits from efficient cache management without compromising functionality.

By leveraging this setup, you can significantly enhance the performance of your e-commerce platform, leading to improved customer satisfaction and potential conversions.

To learn more about advanced Magento optimization techniques, explore our comprehensive guides at Laravel Company.

Happy coding!

Cache Database Performance Admin

Our network