Skip to content

Configuration or annotation invalidation not working in Symfony 2.7.1 #224

Closed
@benr77

Description

@benr77

Hi,

I'm setting up this bundle on Symfony 2.7.1 using the Symfony2 proxy client and of course the Symfony2 HttpCache. If I manually set up invalidation rules in the controller action methods, it works fine and I can see the PURGE requests appearing in the web server logs and the cache is cleared successfully.

However, I cannot get any invalidation to work with the invalidation rules specified either in the YML or as Annotations.

Here is my config

fos_http_cache:
  proxy_client:
    symfony:
      servers: 127.0.0.1
      base_url: dev.localhost
  cache_control:
    defaults:
      overwrite: true
    rules:
      -
        match:
          attributes:
            _route: ^booking$
        headers:
          cache_control: { public: true, max_age: 0, s_maxage: 64000 }
          etag: true
          vary: [Accept-Encoding]

      # match everything to set defaults
      -
        match:
          path: ^/
        headers:
          overwrite: false
          cache_control: { public: false, max_age: 0, s_maxage: 0 }
          etag: false
  invalidation:
    rules:
      -
        match:
          attributes: # When hitting these routes
            _route: "booking_update"
        routes:       # Invalidate cache for the following routes
          booking: ~

As you can see I'm asking it to invalidate the "booking" route when the "booking_update" route is successfully requested. This appears to do nothing.

I have also tried in the BookingUpdateAction() method the annotation

@InvalidateRoute("booking")

I have the SensioFrameworkExtra bundle installed as per the docs.

I have also modified app/AppCache.php as follows:

<?php

require_once __DIR__.'/AppKernel.php';

use Symfony\Component\HttpKernel\HttpKernelInterface;
use FOS\HttpCacheBundle\SymfonyCache\EventDispatchingHttpCache;

/**
 * Class AppCache
 */
class AppCache extends EventDispatchingHttpCache
{

}

Finally, here is my app_dev.php file

<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();

//require_once __DIR__.'/../app/AppKernel.php';
require_once __DIR__.'/../app/AppCache.php';

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$kernel = new AppCache($kernel);

Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();

$response = $kernel->handle($request);

$response->send();

$kernel->terminate($request, $response);

Can anyone shed any light on why the invalidation does not work unless I define it manually in the controller action method?

Alternatively, maybe this is a bug with Symfony 2.7.1

I'm running PHP 5.5.9 on Apache 2.4.7 on Linux Mint 17.1

Thanks

Ben

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions