PHPackages                             volkerschulz/file-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. volkerschulz/file-cache

ActiveLibrary[Caching](/categories/caching)

volkerschulz/file-cache
=======================

PHP file cache handler

1.2.0(2y ago)113MITPHPPHP &gt;=8.0.0

Since Oct 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/volkerschulz/FileCache)[ Packagist](https://packagist.org/packages/volkerschulz/file-cache)[ RSS](/packages/volkerschulz-file-cache/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependenciesVersions (9)Used By (0)

FileCache
=========

[](#filecache)

PHP file cache handler

Installation
------------

[](#installation)

The recommended way to install FileCache is through [Composer](https://getcomposer.org/).

```
composer require volkerschulz/file-cache
```

Usage
-----

[](#usage)

Minimal:

```
use volkerschulz\FileCache;

// Create instance
$filecache = new FileCache('testfiles/cache.png');

// Respond to request
$filecache->respond();
```

With custom header:

```
use volkerschulz\FileCache;

// Create instance for file 'testfiles/utf.json'
// with default options
$filecache = new FileCache('testfiles/utf.json');

// Set additional custom headers (optional)
$filecache->addHeader('Content-Type', 'application/json; charset=UTF8');

// Respond to request
$filecache->respond();
```

With custom options:

```
use volkerschulz\FileCache;

$options = [
    'use_checksum'  => true,
    'hash_algo'     => 'xxh128',
    'fresh_for'     => 300
];

// Create instance for file 'testfiles/utf.json'
// with custom options
$filecache = new FileCache('testfiles/utf.json', $options);

// Set additional custom headers (optional)
$filecache->addHeader('Content-Type', 'application/json; charset=UTF8');

// Respond to request
$filecache->respond();
```

Options
-------

[](#options)

**use\_filetime** *bool*
*Default: true* - Whether to use the file's last modification time when creating the ETag.

**use\_filesize** *bool*
*Default: true* - Whether to use the file's size when creating the ETag.

**use\_checksum** *bool*
*Default: false* - Whether to use the file's hash when creating the ETag. Depending on the filesize this might consume a lot of CPU and I/O time.

> At least one of **use\_filetime**, **use\_filesize**, **use\_checksum** needs to be *true* to create or compare an ETag.

**hash\_algo** *String*
*Default: 'crc32'* - Which hash algorithm to use when **use\_checksum** is *true*. Must be supported by the current PHP version.

**use\_etag** *bool*
*Default: true* - Whether to use an ETag at all. It is strongly recommended to leave that option set to *true*.

**fresh\_for** *int*
*Default: 0* - Number of seconds (from now) the resource is guaranteed not to be stale and should not be revalidated.

**add\_missing\_headers** *bool*
*Default: true* - If set to true, missing headers (currently `Content-Type` only) will be added automatically, if possible.

Security
--------

[](#security)

If you discover a security vulnerability within this package, please send an email to . All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced.

License
-------

[](#license)

This package is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

7

Last Release

1021d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38070181?v=4)[volkerschulz](/maintainers/volkerschulz)[@volkerschulz](https://github.com/volkerschulz)

---

Top Contributors

[![volkerschulz](https://avatars.githubusercontent.com/u/38070181?v=4)](https://github.com/volkerschulz "volkerschulz (20 commits)")

---

Tags

cachingfilesphp

### Embed Badge

![Health badge](/badges/volkerschulz-file-cache/health.svg)

```
[![Health](https://phpackages.com/badges/volkerschulz-file-cache/health.svg)](https://phpackages.com/packages/volkerschulz-file-cache)
```

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[ichhabrecht/intcache

Turn uncachable page objects into cacheable links

193.9k](/packages/ichhabrecht-intcache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
