2017 © Pedro Peláez
 

package cache-response

laravel 5 response cache

image

fts/cache-response

laravel 5 response cache

  • Monday, July 23, 2018
  • by fts3232
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

cache-response

Latest Stable Version Total Downloads License, (*1)

功能

  • 生成静态化页面

安装

composer require fts/cache-response

添加服务提供者

打开 config/app.php 并添加以下内容到 providers 数组:, (*2)

fts\CacheResponse\CacheResponseServiceProvider.php::class

中间件

打开 app/Http/Kernel.php 并添加以下内容到 routeMiddleware 数组:, (*3)

'page-cache' => fts\CacheResponse\Middleware\CacheResponse::class

URL重写

  • 对于nginx:, (*4)

    更新locationtry_files内容, (*5)

    location = / {
        try_files /static/index.html /index.php?$query_string;
    }
    
    location / {
        try_files $uri $uri/ /static/$uri.html /index.php?$query_string;
    }
  • 对于apache:, (*6)

    打开public\.htaccess 添加以下内容, (*7)

    RewriteCond %{REQUEST_URI} ^/?$
    RewriteCond %{DOCUMENT_ROOT}/static/index.html -f
    RewriteRule .? page-cache/index.html [L]
    RewriteCond %{DOCUMENT_ROOT}/static%{REQUEST_URI}.html -f
    RewriteRule . static%{REQUEST_URI}.html [L]

用法

使用中间件

Router::middleware('page-cache')->get('');

清除缓存

uri:可选参数,指定要删除缓存的静态文件, (*8)

php artisan page-cache:clear uri

生成缓存

uri:可选参数,指定要生成缓存的url, (*9)

php artisan page-cache:create uri

配置参数

config/pageCache.php
  • 是否自动失效:, (*10)

    isAutoExpired:true | false
  • 有效时间(分钟):, (*11)

    expire:默认30分钟
  • 缓存目录:, (*12)

    cachePath:path

The Versions

23/07 2018

dev-master

9999999-dev

laravel 5 response cache

  Sources   Download

MIT

The Requires

 

by tianshuo feng

laravel cache response

23/07 2018

v1.0.1

1.0.1.0

laravel 5 response cache

  Sources   Download

MIT

The Requires

 

by tianshuo feng

laravel cache response

14/07 2018

v1.0.0

1.0.0.0

laravel 5 response cache

  Sources   Download

MIT

The Requires

 

by tianshuo feng