PHP Class Codesleeve\AssetPipeline\Filters\ClientCacheFilter

Inheritance: implements Codesleeve\Sprockets\Interfaces\ClientCacheInterface
Show file Open project: codesleeve/asset-pipeline

Protected Properties

Property Type Description
$asset AssetCache AssetCache that asset pipeline will pass to us
$cache Assetic\Cache\CacheInterface Underlying cache driver we use

Public Methods

Method Description
get ( string $key ) : string If we make it here then we have a cached version of this asset found in the underlying $cache driver. So we will check the header HTTP_IF_MODIFIED_SINCE and if that is not less than the last time we cached ($lastModified) then we will exit with 304 header.
getAssetCache ( ) : AssetCache Allows us to know our parent asset cache so we can do stuff like last modified time
getServerCache ( ) : Assetic\Cache\CacheInterface Allows us to get the existing cache
has ( string $key ) : boolean Proxy the $cache has to see if this asset has been cached yet or not
remove ( string $key ) : string Remove this key from session and also remove it from underlying cache driver
set ( string $key, string $value ) Proxy set to use the underlying cache driver
setAssetCache ( Assetic\Asset\AssetInterface $asset ) Allows us to set our parent asset cache (from asset pipeline) so we can do stuff like last modified time
setServerCache ( Assetic\Cache\CacheInterface $cache ) Allows us to delegate the cache driver to this client cache

Private Methods

Method Description
getLastTimeModified ( string $key ) : string Store the last time this file was modified (which we don't know) so we just use the current datetime. We will store this date in $_SESSION so that next time we run we can re-use the datetime we first picked so that our cache isn't busted each time.

Method Details

get() public method

If we make it here then we have a cached version of this asset found in the underlying $cache driver. So we will check the header HTTP_IF_MODIFIED_SINCE and if that is not less than the last time we cached ($lastModified) then we will exit with 304 header.
public get ( string $key ) : string
$key string
return string

getAssetCache() public method

Allows us to know our parent asset cache so we can do stuff like last modified time
public getAssetCache ( ) : AssetCache
return AssetCache

getServerCache() public method

Allows us to get the existing cache
public getServerCache ( ) : Assetic\Cache\CacheInterface
return Assetic\Cache\CacheInterface

has() public method

Proxy the $cache has to see if this asset has been cached yet or not
public has ( string $key ) : boolean
$key string
return boolean

remove() public method

Remove this key from session and also remove it from underlying cache driver
public remove ( string $key ) : string
$key string
return string

set() public method

Proxy set to use the underlying cache driver
public set ( string $key, string $value )
$key string
$value string

setAssetCache() public method

Allows us to set our parent asset cache (from asset pipeline) so we can do stuff like last modified time
public setAssetCache ( Assetic\Asset\AssetInterface $asset )
$asset Assetic\Asset\AssetInterface

setServerCache() public method

Allows us to delegate the cache driver to this client cache
public setServerCache ( Assetic\Cache\CacheInterface $cache )
$cache Assetic\Cache\CacheInterface

Property Details

$asset protected property

AssetCache that asset pipeline will pass to us
protected AssetCache $asset
return AssetCache

$cache protected property

Underlying cache driver we use
protected CacheInterface,Assetic\Cache $cache
return Assetic\Cache\CacheInterface