承接 swisnl/laravel-static-request-cache 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

swisnl/laravel-static-request-cache

最新稳定版本:1.5.0

Composer 安装命令:

composer require swisnl/laravel-static-request-cache

包简介

Cache static responses based on content-type to static files.

README 文档

README

Latest Version on Packagist Software License Buy us a tree Build Status Coverage Status Quality Score Total Downloads Made by SWIS

🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨

We don't use this package anymore in our own projects — we switched to Nginx with FastCGI Caching — and cannot justify the time needed to maintain it anymore. That's why we have chosen to abandon it. Feel free to fork our code and maintain your own copy or use one of the many alternatives. We suggest using silber/page-cache instead as it is fairly similar.

Install

Via Composer

$ composer require swisnl/laravel-static-request-cache

Setup

Add the middleware to the end of your Http/Kernel.php middleware array.

protected $middleware = [
   \Swis\Laravel\StaticRequestCache\Http\Middleware\CacheMiddleware::class,
];

Add the following snippet into your .htaccess

# Rewrite to html cache if it exists and the request is for a static page
# (no url query params and only get requests)
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{DOCUMENT_ROOT}/static/html%{REQUEST_URI} -f
RewriteRule ^(.*)$  /static/html%{REQUEST_URI} [L]

RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{DOCUMENT_ROOT}/static/html%{REQUEST_URI}/index.html -f
RewriteRule ^(.*)$ /static/html%{REQUEST_URI}/index.html [L]

Disabling

If you want to disable the cache for some reason (the content might be dynamic), you can use the StaticRequestCache singleton in the IoC:

public function __construct(StaticRequestCache $staticRequestCache)
{
    $this->staticRequestCache = $staticRequestCache;
    $this->staticRequestCache->disable();
}

Or use the Facade:

StaticRequestCache::disable();

Please note that this package also checks for Cache-control headers and caches accordingly. You can change this behaviour in the config by editing non_cacheable_cache_control_values.

Clear the files

To clear all the files manually you can use an artisan command.

$ php artisan static-html-cache:clear

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email security@swis.nl instead of using the issue tracker.

Credits

Based on mscharl/laravel-static-html-cache. Added configuration for setting cacheable content-type and non-cacheable cache control values.

License

The MIT License (MIT). Please see License File for more information.

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

SWIS ❤️ Open Source

SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-28