volkerschulz/file-cache 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

volkerschulz/file-cache

最新稳定版本:1.2.0

Composer 安装命令:

composer require volkerschulz/file-cache

包简介

PHP file cache handler

README 文档

README

PHP file cache handler

Installation

The recommended way to install FileCache is through Composer.

composer require volkerschulz/file-cache

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

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

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

License

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

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-24