Download the PHP package hardimpactdev/cloudflare-cache without Composer

On this page you can find all versions of the php package hardimpactdev/cloudflare-cache. 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 cloudflare-cache

Cloudflare Cache for Laravel

Easy Cloudflare edge caching for Laravel apps:

Designed for brochure/marketing sites behind Cloudflare — including Laravel Cloud’s Cloudflare edge when you manage the zone yourself for per-URL purge.

Installation

Publish config (optional):

Environment

Create a Cloudflare API token with Zone → Cache Purge limited to the site zone.

Cacheable routes (critical)

Cloudflare will not cache responses that set cookies. Do not put this middleware only on the default web stack.

With Waymaker (recommended)

Keep a single Waymaker-generated routes file. Opt pages into a cookie-free stack with a middleware group:

Per-route override (same controller can mix groups):

StaticMiddleware::defaults() is:

  1. SubstituteBindings
  2. Your $before stack (Inertia share, etc.)
  3. CacheResponse (this package)
  4. Your $after stack

Requires Waymaker with middlewareGroup support (see Waymaker changelog / docs).

Without Waymaker

Alias is also registered for classic routes:

Default headers:

Middleware skips: non-GET, non-2xx, authenticated users, requests with an active session (web group), Set-Cookie responses, disabled env / package.

Cloudflare dashboard

For HTML to be eligible, ensure a Cache Everything (or equivalent) rule with Browser TTL: Respect Origin and Edge TTL: Use cache-control header from origin (Respect Origin). Without the Edge TTL setting, Cloudflare may ignore s-maxage and fall back to its own default. Static extensions are cached by Cloudflare by default.

Inertia + SSR (Cloudflare only)

Document visits and Inertia navigations share the same URL:

Request Expects Edge cache
Full page load SSR HTML Yes — public, s-maxage=…
Inertia XHR (X-Inertia: true) JSON Noprivate, no-store

Cloudflare free/pro does not vary the cache key on X-Inertia. Relying on Vary alone will serve HTML to Inertia navigations — store-side headers alone aren't enough either, so you also need lookup-side Cache Rules on a zone that actually proxies traffic.

This package:

  1. Edge-caches document visits only
  2. Forces private, no-store when X-Inertia is present
  3. Still sets Vary: Accept-Encoding, X-Inertia for correctness elsewhere

Required Cloudflare Cache Rules

Create two Cache Rules, in this order:

  1. Bypass Cache when it's an Inertia navigation:

  2. Cache Everything for other eligible GETs (the document HTML), with:

    • Browser TTL: Respect Origin
    • Edge TTL: Use cache-control header from origin (Respect Origin)

    The Edge TTL setting matters — without it Cloudflare may ignore s-maxage from this package's headers and fall back to its own default Edge TTL instead.

not len(http.request.headers["x-inertia"]) > 0 is not a valid substitute for rule 1 — len() does not operate on an array-valued header field and won't validate.

DNS for the site must be proxied (orange cloud) on that zone. Grey-cloud DNS (DNS only) means your Cache Rules never run — traffic hits Laravel Cloud’s managed edge instead, which cannot set per-header bypass rules.

Warming fetches document HTML only (no X-Inertia header).

There is no second origin cache in this package — only Cloudflare edge headers, purge, and warm.

Purge

Eloquent / Filament

Or call from Filament:

Artisan

Warming

Off after purge by default (CLOUDFLARE_CACHE_WARM_AFTER_PURGE=false). Enable per call with warm: true, or set the env flag globally. Warming issues cookie-less GET requests so the edge can re-fill quickly after invalidation.

Laravel Cloud note

Laravel Cloud’s built-in edge purge API clears the whole environment. This package targets your Cloudflare zone for precise URL purge (Filament saves). Use both: deploy purge from Cloud, content purge from this package.

If the custom domain is DNS-only to Laravel Cloud, HTML may still be edge-cached by Cloud’s Cloudflare when you send public, s-maxage. Without Cache Rules you control, Inertia navigations will get that HTML — either orange-cloud through your zone with the rules above, or stop sharing HTML at the edge (private) for those pages.

Testing

License

MIT


All versions of cloudflare-cache with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/console Version ^12.0||^13.0
illuminate/contracts Version ^12.0||^13.0
illuminate/http Version ^12.0||^13.0
illuminate/support Version ^12.0||^13.0
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 hardimpactdev/cloudflare-cache contains the following files

Loading the files please wait ...