Search code examples
phpsymfonyhttp-caching

How to disable symfony2 http cache globally?


I'm developing website with Symfony2.

Most of pages of the website are highly dynamic and because of that I have problems with HTTP cache.

I found out that if I use function setMaxAge(0) for response, problems would be fixed, but it's not possible now to set it for each response. Is there any way to disable HTTP cache or setMaxAge to 0 globally?


Solution

  • I added this line to construct of Response class:

    $this->setExpires(new \DateTime('1980-01-01'));
    

    I don't think this is such a good idea, but it works!