Download the PHP package bagisto/bagisto-varnish without Composer

On this page you can find all versions of the php package bagisto/bagisto-varnish. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bagisto-varnish

Varnish Integration for Bagisto

This package puts Varnish Cache in front of a Bagisto storefront, so a cached page is served without touching PHP at all, while personalised parts of the page still come from the application through ESI (Edge Side Includes) or AJAX dynamic views.


📌 Features


🔄 How it fits together

Varnish sits between your public web server and Bagisto. Three processes, three ports:

The single most common mistake is confusing the two host settings. They describe different hops, and getting them the wrong way round fails silently — pages cache but never update:

Setting Describes Used for
Varnish Host URL Varnish itself (:6081) Where Bagisto sends PURGE requests. Wrong value ⇒ nothing is ever purged.
Backend Host URL / Port Bagisto's own web server (:8080) What is written into the exported VCL as Varnish's backend. Wrong value ⇒ Varnish cannot reach your site.

Ports above are examples — use whatever your server actually listens on. Confirm with:


✅ Requirements

On an older Bagisto, install the matching package version from the table below instead — the releases are not interchangeable, because each one tracks the storefront views and the configuration tree of its own Bagisto line.

Version compatibility

Package Bagisto PHP Released Install with
2.2.0 2.5.x 8.4+ (^8.4) Oct 2026 composer require bagisto/bagisto-varnish:^2.2
2.1.0 2.4.x 8.3 – 8.4 (>=8.3 <8.5) Aug 2026 composer require bagisto/bagisto-varnish:^2.1
2.0.0 2.4.x 8.3 – 8.4 (>=8.3 <8.5) Mar 2026 superseded — use 2.1.0
1.1.0 2.3.7 as Bagisto 2.3 requires Sep 2025 composer require bagisto/bagisto-varnish:^1.1
1.0.0 2.3.x as Bagisto 2.3 requires Sep 2025 superseded — use 1.1.0

The PHP range is Bagisto's own for that line; only 2.2.0 declares php in its composer.json. Varnish 6.0+ applies to every row.

Two upgrades are not drop-in, so check them before moving between lines:

Moving to What changes
2.0.0 (Bagisto 2.4) The provider moves from config/app.php's 'providers' => [...] array to the flat array in bootstrap/providers.php, and the configuration key is renamed fpc → varnish. Settings saved under fpc are not carried over — re-enter them under Cache Management → Varnish.
2.2.0 (Bagisto 2.5) The three published storefront views are rebased on their 2.5 originals. Already-published copies are not overwritten by step 3, so re-publish them explicitly or the 2.5 header and product card stay reverted to the 2.4 markup:
php artisan vendor:publish --provider="Webkul\Varnish\Providers\VarnishServiceProvider" --force

Development happens on a single master branch, which tracks the newest Bagisto line. There is no long-lived 2.4 branch: the 2.4 line is held by the v2.1.0 tag.


📦 Installation

1. Install via Composer

2. Register the service provider

Bagisto 2.5 keeps providers in bootstrap/providers.php, which returns a flat array — not the 'providers' => [...] block used by older Laravel versions:

Order matters, and auto-discovery is deliberately disabled. The provider re-registers the cache.response middleware alias so storefront routes are tagged for Varnish instead of being stored by Bagisto's built-in page cache. Registered before the Shop package, the Shop package would simply overwrite it again and nothing would be tagged.

3. Publish the config


⚙️ Configuration

Do this before exporting the VCL — the VCL file is generated from these values.

Go to Admin → Configuration → Cache Management → Varnish → Configuration.

  1. Set Cache Application to Varnish.

    The remaining fields stay hidden until you do — they depend on this one. If you cannot see the settings below, this is why.

  2. Fill in the rest:
Field Example Notes
Access List localhost,127.0.0.1,::1 IPs allowed to issue PURGE. Must include the host Bagisto runs on.
Varnish Host URL 127.0.0.1:6081 Where purges are sent. See the table above.
Backend Host URL 127.0.0.1 Host only — a scheme or port here is ignored, the port has its own field.
Backend Host Port 8080 The port your backend web server listens on, not Varnish's.
Grace Period 3d How long stale content may be served while the backend is slow or down.
  1. Save.

Keeping the settings

These live in core_config, so anything that rebuilds the database (bagisto:install, which runs db:wipe + migrate:fresh) removes them. On a demo or CI environment that reinstalls regularly, seed the values instead of entering them by hand.


🖥 Install the VCL

  1. Admin → Configuration → Cache Management → Varnish → Configuration → Export VCL. The downloaded file already contains the backend host, port, access list and grace period you configured above.

  2. Put it in place and reload:

    The -C step compiles without applying — always run it first, since a bad VCL will stop Varnish from starting.

  3. Purge everything once, so nothing cached under an older configuration is left behind.

A ready-made copy also ships at vcls/6.0.vcl for reference, but prefer the exported file: that one carries your own settings.


🔬 Verify it is working

X-Bagisto-Cache-Debug reports HIT, MISS or UNCACHEABLE. If you never see HIT, Varnish is not in the request path. If you see HIT but it never returns to MISS after an edit, your Varnish Host URL is wrong.


🛡 Automatic cache purging

Purging happens on its own when:

A purge clears the page in every channel, locale and currency it was cached under, so it does not matter which locale the admin happened to be in when saving.

To purge from your own code:

Or from the command line:

Upgrading from an older version: a cached page carries the tags it will later be purged by, so pages already sitting in Varnish still hold the old tag format. Run Purge Everything once after deploying.


🛠 Manual cache management

Admin → Configuration → Cache Management → Varnish → Purge Cache


🎨 Theme integration

Personalised fragments must be pulled out of the cached page. Declare each one in config/varnish.php:

Then include it one of two ways:

ESI include

Assembled by Varnish itself, so it is present in the first paint. A slow backend will hold up the whole page.

AJAX dynamic view — recommended

Fetched after the page renders. Better LCP/FCP, and the right choice for dropdowns, modals and menus that are not needed immediately.


🗂 Cache-Control headers

Routes that should be cached carry:

The lifetime goes to s-maxage, which only shared caches such as Varnish honour, while browsers are asked to revalidate. This matters: a purge reaches Varnish alone, so giving the same lifetime to max-age would leave every visitor who had already loaded the page holding a private copy for a week that nothing could invalidate.

Routes that must not be cached should send:

Attach the middleware to any route you want cached and tagged:

The lifetime is a middleware argument in minutes — cache.response:1440 for a day. It defaults to 7 days.


🧯 Troubleshooting

Symptom Cause Fix
Changes never appear on the storefront Purges are not reaching Varnish Check Varnish Host URL points at Varnish's port, not the backend's or nginx's. A purge sent to nginx returns 301 and is silently lost.
X-Bagisto-Cache-Debug never appears Varnish is not in the request path Check your web server proxies to Varnish.
Always MISS, never HIT Response is not cacheable Look for Cache-Control: private/no-store, or a Set-Cookie on the response.
Purge reports success, page still stale The cached object predates an upgrade Run Purge Everything once.
Page updates for a new visitor but not for you Your browser cached it Hard-reload. Confirm the response sends max-age=0.
Exported VCL will not compile Backend host contains a scheme or port Put the host alone in Backend Host URL; the port has its own field.
405 Method not allowed on purge The purging host is not in the ACL Add it to Access List and re-export the VCL.
Settings vanished after a reinstall bagisto:install wipes the database Seed the core_config values instead of entering them by hand.

🚀 Best practices


All versions of bagisto-varnish with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bagisto/bagisto-varnish contains the following files

Loading the files please wait ...