Provides a httpcache warmup command for Symfony2

Installs: 1 230

Dependents: 0

Stars: 30

Watchers: 3

Forks: 2

Open Issues: 1

Type: symfony-bundle

v2.0.0 2015-05-19 18:11 UTC


Build Status Scrutinizer Code Quality Code Coverage StyleCI Latest Stable Version License

Provides a httpcache warmup command for Symfony2. The command simply executes a GET request on a list of urls. One or more url providers must be registered. This bundle requires an implementation of php-http/adapter and php-http/message-factory. The bundle will try and auto-discover these if not configured directly.


  1. Add to your composer.json:

    $ composer require zenstruck/cache-bundle
  2. Register this bundle with Symfony2:

    // app/AppKernel.php
    public function registerBundles()
        $bundles = array(
            // ...
            new Zenstruck\CacheBundle\ZenstruckCacheBundle(),
        // ...


An http_adapter (class or service implementing Http\Adapter\HttpAdapter) and message_factory (class or service implementing Http\Message\MessageFactory) must be configured.

    http_adapter:    Acme\MyHttpAdapter    # or a service (acme.my_http_adapter)
    message_factory: Acme\MyMessageFactory # or a service (acme.my_message_factory)

If left blank, the bundle will try and auto-discover these classes. The following HTTP adapters and are message factories are currently auto-discoverable:

  • guzzle6-adapter (Provides HttpAdapter and allows discovery of MessageFactory)

    composer require php-http/guzzle6-adapter
  • guzzle5-adapter (Provides HttpAdapter) and guzzlehttp/psr7 (allows discovery of MessageFactory)

    composer require php-http/guzzle5-adapter guzzlephp/psr7

HttpCache Warmup Command


app/console zenstruck:http-cache:warmup

Sitemap Provider

This bundle comes with a URL provider that looks at a list of sitemaps to retrieve a list of urls. If a url is given without the sitemap or sitemap index, the provider first looks for a {url}/sitemap_index.xml to find a set of sitemap files. If no index is found, it defaults to using {url}/sitemap.xml.

To enable the sitemap provider, configure it in your config.yml:

            - http://example.com/sitemap.xml # detects if sitemap or sitemap index and act accordingly
            - http://example.com/en/sitemap.xml # same as above
            - http://www.example.com # trys http://example.com/sitemap_index.xml and http://example.com/sitemap.xml

Add a Custom URL Provider

  1. Create a class that implements Zenstruck\CacheBundle\Url\UrlProvider:

    use Zenstruck\CacheBundle\Url\UrlProvider;
    namespace Acme;
    class MyUrlProvider implements UrlProvider
        public function getUrls()
            $urls = array();
            // fetch from a datasource
            return $urls;
        public function count()
            return count($this->getUrls());
  2. Register the class as a service tagged with zenstruck_cache.url_provider:

        class: Acme\MyUrlProvider
            - { name: zenstruck_cache.url_provider }

Full Default Config

    # Either a class or a service that implements Http\Adapter\HttpAdapter. Leave blank to attempt auto discovery.
    http_adapter:             ~

    # Either a class or a service that implements Http\Message\MessageFactory. Leave blank to attempt auto discovery.
    message_factory:          ~

        enabled:              false
        sitemaps:             []