2017 © Pedro Peláez
 

library laravel-route-cache

Simple Cache for Laravel Routes sending 304 and cached static content

image

ipunkt/laravel-route-cache

Simple Cache for Laravel Routes sending 304 and cached static content

  • Monday, July 28, 2014
  • by justb81
  • Repository
  • 4 Watchers
  • 5 Stars
  • 71 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Route Cache for Laravel 4.x

Latest Stable Version Latest Unstable Version License Total Downloads, (*1)

This package simplifies caching of static pages in your laravel project. It sends 304 status headers and (if available) static html without running the controller. The configuration ist easy and straight forward using a single route-filter., (*2)

Installation

Add to your composer.json following lines, (*3)

"require": {
    "ipunkt/laravel-route-cache": "~1.0.0"
}

Run php artisan config:publish ipunkt/laravel-route-cache, (*4)

Add 'Ipunkt\LaravelRouteCache\LaravelRouteCacheServiceProvider', to providers in app/config/app.php., (*5)

Configuration

Edit config.php in app/config/packages/ipunkt/laravel-route-cache to your needs., (*6)

How to use as Laravel Route-Filter

Add 'before' => 'cache.before' to every route you like to cache. The route has to be canonical!, because the filter caches just by extracting the url() from the Request. (maybe i change that to fullUrl()), (*7)

To outdate a cache, just fire the Event entity.modified and attach the Request or URL of the modified ressource. You can force that on your browser by attaching the GET-Parameter set in your config as cachebuster (default is "renew-cache") to the URL., (*8)

If the infoheader config setting is not false the library adds a Header to the Response to show wether the content came from cache or the controller., (*9)

Other usages

The class Ipunkt\LaravelRouteCache\RouteCache works out of the box without the filter. You can use it in your controllers, (*10)

// get RouteCache-Instance
$routecache = \App::make('routecache');
$routecache->setEntityFromRequest($request);
// or
$routecache->setEntityFromUrl($url);

// to remove the cache
$routecache->removeCache()

// to check if the client has a valid (same ETag) Cache
$routecache->checkClientHasValidCache()

// to save a Response to the Cache
$routecache->setCacheFromResponse(Response $response)

// to save string-content to the Cache
$routecache->setCacheFromContent($content)

// to get a saved Response from the Cache
$routecache->getResponseFromCache()

// to get a saved string from the Cache
$routecache->getContentFromCache()

// you can get the ETag for the entity (but you don't need it)
$routecache->getETag()

// you can even set a custom ETag if you like
$routecache->getETag($value)

Open TODOs

Feel free to fork and push changes * remember all cached entities and allow to clear them with a Command * add TestCases * cache content-type of the content and respond with that. * Routines to handle POST, PUT, UPDATE and DELETE Requests, (*11)

The Versions

28/07 2014

dev-master

9999999-dev

Simple Cache for Laravel Routes sending 304 and cached static content

  Sources   Download

MIT

The Requires

 

by Bastian Rang (ipunkt Business Solutions)

28/07 2014

1.0.3

1.0.3.0

Simple Cache for Laravel Routes sending 304 and cached static content

  Sources   Download

MIT

The Requires

 

by Bastian Rang (ipunkt Business Solutions)

25/07 2014

1.0.2

1.0.2.0

Simple Cache for Laravel Routes sending 304 and cached static content

  Sources   Download

MIT

The Requires

 

by Bastian Rang (ipunkt Business Solutions)

25/07 2014

1.0.1

1.0.1.0

Simple Cache for Laravel Routes sending 304 and cached static content

  Sources   Download

MIT

The Requires

 

by Bastian Rang (ipunkt Business Solutions)

25/07 2014

1.0.0

1.0.0.0

Simple Cache for Laravel Routes sending 304 and cached static content

  Sources   Download

MIT

The Requires

 

by Bastian Rang (ipunkt Business Solutions)