ademes/acetone 问题修复 & 功能扩展

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

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

ademes/acetone

Composer 安装命令:

composer require ademes/acetone

包简介

Laravel5 package for purging & banning cached items in Varnish

README 文档

README

Laravel5 package for purging, refreshing & banning cached items in Varnish

Using web accelerators such as varnish to speed up your web application has become common place. This small package is designed to alleviate the problem of cache expiration with dynamic data generated sites.

Installation

Begin by adding the following to your composer.json

"require": {
    "jdare/acetone": "dev-master"
}

Run a composer update composer update

Add it to your list of providers in laravel /app/app.php

'providers' => array(
    ...
    'JDare\Acetone\AcetoneServiceProvider',
),

Publish the configuration file using php artisan config:publish jdare/acetone

Configuration

Open the newly generated config file app/config/packages/jdare/acetone/config.php

The configurable options are:

  • Server Address
  • Force Exceptions
  • Ban URL Header

The documentation for each option is available inside the file.

Usage

Please Note: All these functions assume some sort of standard VCL setup for purging/refreshing/banning. Please check the docs folder for a reference on how your varnish should interpret these requests.

For the differences between Purge, Refresh and Ban, please check the Varnish documentation.

##Purge & Refresh When you need to invalidate your cache, you can provide a URL to be removed as a parameter for Acetones functions. Here are some sample usages:

function someAction()
{
    //update some information in a template or database
    
    Acetone::purge("/post/my-updated-post"); //Removed old version from Varnish
    
    //Alternatively use Acetone::refresh("/post/my-updated-post") if it suits your caching needs better.
}

Both Purge and Refresh will accept arrays of URL's, however be warned each url will need an individual request to varnish. This can end up having a large overhead and can massively increase your response time.

To better invalidate mass URL's use Ban or BanMany

##Ban & BanMany

Ban will work the same way as Purge and Refresh if needed, however it can also accept an optional parameter to make it match a Regex string rather than a URL.

function someAction()
{
    //update some information in a template or database
    
    Acetone::ban("^/post", true); //will remove any URL's matching "/post(.*)"
}

A helper function is available for mass banning, called "banMany", e.g.

Acetone::banMany("/post"); //will ban any URL starting with /post

ban & banMany are much more efficient ways to remove lots of URL's due to Varnish' pattern matching, rather than having to make a single request for every URL.

FAQ

Purge returns a 404 exception.

Client error response [status code] 404 [reason phrase] Not in cache [url] *URL*

If your VCL is setup to throw a 404 when a purge item is not in the cache, Guzzle will throw an exception. These will only occur locally and be supressed automatically when used in a production environment. However you can disable them permanently, by setting force_exceptions to false in the config.php

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-01-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固