PHP code example of adsazad / symfony-etagging

1. Go to this page and download the library: Download adsazad/symfony-etagging library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adsazad / symfony-etagging example snippets


// Add at the top of class
use Adsazad\SymfonyEtaggingBundle\Util\EtaggingInterface;

// Your action
public function myaction(Request $request, EtaggingInterface $etag){
  $response = $this->render('mypage.twig',['parameters'=>'p1']);

// Return Etag Response
  return $etag->etagResponse($response);
}

// Add Costum Headers
  $ets->addCustom($key, $value);

 // Set Max Age In Seconds (Default 1 Day)
  $ets->setMaxAge(60*60*24); // 1 Day
    
// Set Max Age In Seconds (Default 1 Day)
  $ets->setSharedMax(60*60*10); // 10 Hours