Last active
December 11, 2015 22:18
-
-
Save jenkoian/4668261 to your computer and use it in GitHub Desktop.
An interface used to implement caching on a controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\DemoBundle\Controller; | |
/** | |
* Any controller that implements this interface will be eligible for caching. This works by an event | |
* listener that will look to see if the controller implements this interface and if it does, will call its | |
* getLastModifiedDate() method to check if the content has been modified or not. If not, | |
* then it will tell the controller to simply return the 304 response. | |
* | |
*/ | |
interface Cacheable | |
{ | |
/** | |
* @return boolean Based on the last modified date determine whether the response has changed or not | |
*/ | |
public function isNotModified(\DateTime $lastModified); | |
/** | |
* Work out the last modified date for our caching strategy | |
* @return \DateTime | |
*/ | |
public function getLastModifiedDate(); | |
/** | |
* @return Response The last modified response | |
*/ | |
public function getLastModifiedResponse(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment