Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel File Cache

Laravel File Cache Laravel Package

biigle/laravel-file-cache

A Laravel package for caching file contents and related data with automatic invalidation when the underlying file changes. It provides a simple file-aware cache layer to speed up repeated reads while keeping cached results fresh.

View on GitHub
Deep Wiki
Context7

Fetch and cache files from local filesystem, cloud storage or public webservers in Laravel

Frequently asked questions about Laravel File Cache
How do I install biigle/laravel-file-cache in a Laravel application?
Install it with composer require biigle/laravel-file-cache. The package ships a service provider and facade that are registered through Laravel's package auto-discovery, so no manual wiring is needed in a standard app. After installing, publish the config file to define your cache path and any file source disks. Then make sure the configured cache directory is writable by the application.
Which Laravel and PHP versions does laravel-file-cache support?
The package follows Laravel 8 through 11 era conventions and is built around the filesystem and HTTP client components of that generation. Exact PHP and Laravel constraints are declared in its composer.json, so check those before adopting it in an older or newer application. Because the Flysystem major version differs across Laravel releases, verify the package's Flysystem constraint matches your app before upgrading Laravel.
Does laravel-file-cache work with S3, GCS, or other cloud storage disks?
Yes. Sources are resolved through Laravel filesystem disks, so any Flysystem-backed driver configured in config/filesystems.php, including S3, GCS, or Azure, works without package-specific code. Credentials, regions, and endpoints come from your existing disk configuration. Files fetched from remote disks are cached locally, so the cache directory still needs to be on storage your app can write to.
How does automatic cache invalidation work when the underlying file changes?
The package stores file metadata alongside the cached contents and compares it against the current source on access, so a changed file is re-fetched instead of serving stale content. That means the cache stays fresh without you manually clearing entries after every upload or deploy. For sources where change detection is expensive or unavailable, you can still fall back to explicit clearing through the facade.
Can I cache files fetched from public HTTP or HTTPS URLs?
Yes, public URLs are one of the three supported source types alongside Laravel disks and raw local paths. HTTP fetching goes through Laravel's HTTP client, so proxy, timeout, and retry settings configured in your app are inherited. If URLs can come from user input, validate the scheme and host and enforce a maximum size at the call site to avoid SSRF and resource exhaustion.
What is the difference between get and getOnce in laravel-file-cache?
get returns the cached contents when a valid entry exists and fetches the file again only when the source has changed, making it the normal choice for repeated reads. getOnce bypasses the existing cache entry and fetches the file fresh, then updates the cache with the new result. Use getOnce when you specifically need to force a refresh, for example after an out-of-band write you know about.
How do I clear the file cache and stop it growing unbounded in production?
The facade exposes clear and delete methods so you can remove cached entries programmatically, and the package provides a prune command for scheduled cleanup. Without a scheduled prune job the cache directory grows indefinitely, so add the command to your scheduler and monitor disk usage. Also confirm the cache path is on persistent storage, since ephemeral container filesystems silently discard it on every deploy.
Is the laravel-file-cache cache shared across multiple servers?
The cache is a filesystem directory, so by default it is node-local and each instance maintains its own copy. In a load-balanced deployment you either accept per-node caches or point the configured cache path at a shared volume, accepting the latency and locking characteristics of that volume. The package is not a distributed cache and does not provide cross-node coherence guarantees.
Is it safe to cache user-supplied URLs with this package?
Only with guardrails. The package will fetch whatever URL you hand it, so untrusted input turns it into an SSRF surface that can reach internal services or metadata endpoints. Restrict schemes to http and https, block private and link-local address ranges, enforce a maximum file size, and set short timeouts and redirect limits before calling the package. Treat the package as a fetch-and-cache primitive, not a security boundary.
How does laravel-file-cache compare to Laravel's built-in cache or response caching?
Laravel's cache stores whatever value you put in it, so you have to derive keys and decide when to invalidate yourself. This package adds file awareness, meaning cached contents are tied to a specific source file and refreshed when that file changes, plus a single cache directory you can prune. It is not a CDN, asset manager, or replacement for HTTP response caching, so use it for repeated reads of files rather than replacing your whole cache layer.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo