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)213MITPHPPHP &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 1mo 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 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

929d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/efc7fb4086dc6a18bd030ac96622a18992f4d868596b3d0a3201759dac6135e1?d=identicon)[volkerschulz](/maintainers/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

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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