2017 © Pedro Peláez
 

symfony-bundle page-cache-bundle

image

bigyouth/page-cache-bundle

  • Friday, January 19, 2018
  • by bigyouth
  • Repository
  • 3 Watchers
  • 4 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Big Youth Page Cache Bundle

| Maintainability | Issues | Downloads | Release | |:----------------------:|:-----------------------:|:-----------------------:|:-----------------------:| Maintainability | Issues | Downloads | Release |, (*1)

What is it ?

This bundle provides a simple page caching solution working as an in-app reverse proxy., (*2)

Requirements

"php": "^5.3.9|^7.0",
"symfony/cache": "^3.1"

Installation

Download the bundle

Download composer at https://getcomposer.org/download/, (*3)

composer require bigyouth/page-cache-bundle

Register the bundle

Enable the bundle by adding it to the bundles array of the registerBundles method in your project's app/AppKernel.php file :, (*4)

<?php

# app/AppKernel.php

// ...

class AppKernel extends Kernel
{
        public function registerBundles()
        {
            $bundles = [
                // ...

                new Bigyouth\BigyouthPageCacheBundle\BigyouthPageCacheBundle(),
            ];

            // ...
        }

        // ...
}

Configuration

Here is the default bundle configuration :, (*5)

# app/config/config.yml


bigyouth_page_cache:
    enabled: false
    ttl: 300
    type: "filesystem"
    exclude: []

enabled

default : false

Set to true to enable the bundle., (*6)

ttl

default : 300

Cache lifetime. This value varies by +5%/-5% to avoid multiple caches to expire at the same time., (*7)

type

default: filesystem

Two value can be set for this parameter : filesystem and redis., (*8)

If you use filesystem, the cache will be written in the cache folder : var/cache/by_cache., (*9)

exclude

default : empty array

This parameter allows you to define url schemes that will be excluded from the page caching., (*10)

ex :, (*11)

exclude:
    - "app_dev.php"
    - "back"
    - "login"
    - "logout"
    - "login_check"

Every url that contains one of the terms above will not be processed by the BigyouthPageCacheBundle., (*12)

redis_host

default : localhost

Redis host. This parameter is only used when the type parameter is set to redis., (*13)

redis_port

default : 6379

Redis port. This parameter is only used when the type parameter is set to redis., (*14)

Usage

Caching

To use the BigyouthPageCacheBundle, your controller must extend the PageCacheController.php class and use the render function :, (*15)

<?php

// ...

class AcmeController extends PageCacheController
{

        // ...
        public function indexAction(Request $request)
        {

            // ...

            return $this->render('FrontBundle:Page:index.html.twig');

        }
}

The PageCacheController rewrites the render function to manage and render cache data. All of your controller actions that use the render function will be cached., (*16)

Cache invalidation

The BigyouthPageCacheBundle uses cache tags to identify your cache data. The tags are defined by the url scheme of the cached page., (*17)

For example, the page behind /products/list/my-product will be tagged with products, list and my-product., (*18)

Therefore you can invalidate a product page by doing the following in your controller :, (*19)

// ...

$this->get('by.page_cache')->invalidate(["my-product"]);

// ...

or if you want to invalidate all product pages :, (*20)

// ...

$this->get('by.page_cache')->invalidate(["products"]);

// ...

Authors

  • Alexis Smadja - Initial work - Alxss

See also the list of contributors who participated in this project., (*21)

License

This project is licensed under the MIT License - see the LICENSE file for details., (*22)

The Versions

19/01 2018

dev-dev

dev-dev

  Sources   Download

MIT

The Requires

 

by Alexis Smadja

19/01 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Alexis Smadja

18/01 2018

dev-styleci

dev-styleci

  Sources   Download

MIT

The Requires

 

by Alexis Smadja

17/01 2018

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

by Alexis Smadja