symfony 3.4 cache control

<?php

namespace AppBundle\Listener;

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;

class ResponseListener
{
    public function onKernelResponse(FilterResponseEvent $event)
    {
        $response = $event->getResponse();

        $controller = $event->getRequest()->attributes->get('_controller');
        $requiredAssetAction = "AppBundle\Controller\Website\AssetsController::assetAction";

        if ($controller == $requiredAssetAction) {
            $response->headers->addCacheControlDirective('max-age', 900);
            $response->headers->addCacheControlDirective('s-maxage', 900);
            $response->headers->addCacheControlDirective('must-revalidate', true);
            $response->headers->addCacheControlDirective('public', true);
            $response->headers->removeCacheControlDirective('private');

        }

        $event->setResponse($response);
    }

}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
symfony cache de~ symfony cache de_ clear cache symfony 1.4 Symfony cache package symfony 4 clear cache from controller clear cache symfony 3 symfony work without using cache clear cache symfony 3.4 symfony 2.8 cache clear symfony 3 clear cache command symfony cache plugin symfony 5 cache clear implement symfony cache symfony remove cache control class cache symfony clean cache symfony in controller symfony cache problems symfony 3.4 cache symfony composer require symfony cache composer install symfony cache symfony DO Add cache annotation symfony set response header cache-control symfony cache forms php cache symfony html symfony annotations cache symfony 3 clear cache cache component symfony symfony command cache symfony 4 rest api caches cache symfony 4.4 component cache symfony 4.4 page de cache symfony symfony cache-&gt;contains get cache symfony 4.4 symfony cache config options symfony 4 disable cache http cache symfony symfony file system cache tutorial symfony cache tutorial symfony generate cache handle cache symfony cache container symfony symfony 5 clear cache symfony finder cache symfony cache interface symfony cache documentation symfony set Cache-control header cache symfony symfony cache servuce symfony cache manager cache clear symfony 4 composer symfony cache generate cache symfony from command line Symfony HTTP cache symfony retrieve http cache store symfony cache interface get cache clear symfony 3.4 symfony cache components tests symfony config cache symfony 4 doctrine cache php symfony 1.4 cache put time symfony 4.4 cache symfony 4 cache clear error clear cache symfony 5 symfony type de cache doctrine symfony doctrine cache symfony get simple cache service symfony service get cache symfony Cache-Control header no-cache symfony Cache-Control header symfony Cache-Control cache symfony problem cache clear symfony 3.3 symfony cache component symfony 3.4 cache clear symfony 2 cache service symfony 2 cache symfony caching a page symfony cache example symfony cache symfony cache warmup symfony cache page symfony 5 cache control always 0 symfony 5 cache header not working symfony cache header nogt working symfony cache header nog working symfony cache control return private symfony cache controller symfony caching resonse symfony https cache issue symfony add http Cache-Control symfony 4 cache response header symfony no cache header symfony no cache $response-&gt;setSharedMaxAge(3600); symfony 3.4 cache control
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source