dafiti / httpcache-listener
Dafiti HttpCache 响应监听器,适用于 Silex 应用程序
此软件包的官方仓库似乎已消失,因此该软件包已被冻结。
1.0.0
2016-06-23 18:03 UTC
Requires
- php: >=5.5.0
- symfony/event-dispatcher: ~2.3|3.0.*
- symfony/http-kernel: ~2.3|3.0.*
Requires (Dev)
- fabpot/php-cs-fixer: @stable
- phpunit/phpunit: @stable
- silex/silex: ~1.3.4
Suggests
- dafiti/config-service-provider: A simple way to manage config files in Silex
This package is not auto-updated.
Last update: 2021-06-23 09:03:52 UTC
README
为 Silex 和 Symfony 应用程序自动设置响应头(Etag 和 MaxAge)
安装
此软件包可在 Packagist 上找到。支持 PSR-4 自动加载。
{ "require": { "dafiti/httpcache-listener": "dev-master" } }
用法
基础 - Silex
use Dafiti\Subscriber; use Pimple; use Silex\Application; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; $app = new Application(); // You can use dafiti/config-service-provider to manage the config files $app['config'] = new Pimple(); $app['config']['http_cache'] = [ 'enabled' => true, 'etag' => true, 'max_age' => 100 ]; $app['dispatcher']->addSubscriber(new Subscriber\HttpCache($app['config']['http_cache'])); });
基础 - Symfony
# Register HttpCache configuration into config.yml: parameters: http_cache: enabled: false # If enabled, all routes will be cached max_age: 10 etag: true # Register subscriber into services.yml: httpcache_subscriber: class: Dafiti\Subscriber\HttpCache arguments: ['%http_cache%'] tags: - { name: kernel.event_subscriber } # Define the routes to be cached or not: app_index: path: '/' methods: [GET] defaults: _controller: AppBundle\Controller\DefaultController::indexAction http_cache: enabled: true max_age: 100 etag: false
许可
MIT 许可证