Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/adsazad/symfony-etagging

Etagging bundle for symfony to increase speed of your webpage
https://github.com/adsazad/symfony-etagging

cache caching etag php symfony symfony-bundle

Last synced: about 1 month ago
JSON representation

Etagging bundle for symfony to increase speed of your webpage

Awesome Lists containing this project

README

        

# Etagging Bundle For Symfony

### Installation
```
composer require adsazad/symfony-etagging
```

# Usage
etagResponse() function will work on any symfony response.

```php
// Add at the top of class
use Adsazad\SymfonyEtaggingBundle\Util\EtaggingInterface;
```
```php
// Your action
public function myaction(Request $request, EtaggingInterface $etag){
$response = $this->render('mypage.twig',['parameters'=>'p1']);

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

### Add Custom Headers
Add This before Etag Response
```php
// Add Costum Headers
$ets->addCustom($key, $value);
```

## Set Max Age
```php
// 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
```