Search
 
SCRIPT & CODE EXAMPLE
 

PHP

symfony 3.4 cache control

<?php

namespace AppBundleListener;

use SymfonyComponentHttpKernelEventFilterResponseEvent;

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

        $controller = $event->getRequest()->attributes->get('_controller');
        $requiredAssetAction = "AppBundleControllerWebsiteAssetsController::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);
    }

}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel empty 
Php :: laravel wherein like 
Php :: error handling in laravel 
Php :: send email php smtp 
Php :: Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255 
Php :: wordpress add action 
Php :: merge strings in php 
Php :: php integer variable 
Php :: how pass optional route parameter in laravel 
Php :: what is actullay work model in laravel 
Php :: split functions.php 
Php :: how to give points to referrer in laravel 
Php :: readable var dump php 
Php :: include vendor/autoload.php 
Php :: laravel - access file from storage path - alternative to symlink 
Php :: laravel $browser-keys alt click 
Php :: enableQueryLog 
Php :: store data array in php of input field 
Php :: radio button in php form 
Php :: laravel 7 factory tinker 
Php :: confiruando passaport no laravel 
Php :: Laravel FileManager Display Blank pop up page 
Php :: make a global php function in laravel so that accessed anywhere 
Php :: php limit results by 30 days 
Php :: Laravel Exclude URI from csrf token verification 
Php :: php-like-system-with-notification-using-ajax-jquery 
Php :: php When I try to run my code in chrome, i see the code that I have made in phpstorm and not the function that it has to do 
Php :: if gd is image 
Php :: controller run 
Php :: Natural numbers from php 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =