PHPackages                             pixelcode/cacheheadercontrol - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. pixelcode/cacheheadercontrol

ActiveCraft-plugin

pixelcode/cacheheadercontrol
============================

Craft plugin for setting HTTP cache control headers

1.0.0(9y ago)0217MITPHP

Since Feb 8Pushed 9y ago3 watchersCompare

[ Source](https://github.com/PixelCodeNL/cache-header-control)[ Packagist](https://packagist.org/packages/pixelcode/cacheheadercontrol)[ RSS](/packages/pixelcode-cacheheadercontrol/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Craft HTTP cache header control plugin
======================================

[](#craft-http-cache-header-control-plugin)

[![Build Status](https://camo.githubusercontent.com/22b90bcb21cf7a4e0d6f8b2f181cec4ef6cac6e95107c76b4c058bc54b21c35e/68747470733a2f2f7472617669732d63692e6f72672f506978656c436f64654e4c2f63616368652d6865616465722d636f6e74726f6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/PixelCodeNL/cache-header-control)[![Code Climate](https://camo.githubusercontent.com/0829199a32f565dba8cf21a709ba3310fdf3e061e7544915626560e3819b1b58/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f506978656c436f64654e4c2f63616368652d6865616465722d636f6e74726f6c2f6261646765732f6770612e737667)](https://codeclimate.com/github/PixelCodeNL/cache-header-control)[![Test Coverage](https://camo.githubusercontent.com/346a3a1b885219b69b01768589fdfeb22f8d2d68496f416eaa03f3c28387a98c/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f506978656c436f64654e4c2f63616368652d6865616465722d636f6e74726f6c2f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/PixelCodeNL/cache-header-control/coverage)[![Issue Count](https://camo.githubusercontent.com/dc2a52063cfa7c11bc8b412bebd1c21094359d4998ac94195da42948eeb66f66/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f506978656c436f64654e4c2f63616368652d6865616465722d636f6e74726f6c2f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/PixelCodeNL/cache-header-control)

This plugin makes it easier to set up an Cache-Control and Expiration HTTP header from your templates.

Installation
------------

[](#installation)

Install it with Composer:

```
composer require pixelcode/cacheheadercontrol

```

Usage
-----

[](#usage)

Use it in your template(s):

```
{% http_cache %}

```

This will set the headers based on the plugin configuration.

```
{% http_cache false %}

```

This will disable cache for the template.

```
{% http_cache '+5 minutes' %}

```

This will set the cache expiration to 5 minutes after the current time, so the template will be cached for 5 minutes.

You can use all 'strtotime' formats here, see .

Configuration
-------------

[](#configuration)

### Options

[](#options)

#### enableCache

[](#enablecache)

Default: `true`

Enable or disable cache headers. If this is set to 'false' and you add the 'http\_cache' tag to a template, the Expiration header will get the value of {time} - 1 second.

#### defaultCacheExpiration

[](#defaultcacheexpiration)

Default: `+15 minutes`

Default expiration used when you use '{% http\_cache %}' without any custom options.

### Overwrite configuration

[](#overwrite-configuration)

You can overwrite the configuration by creating a PHP file with the name 'cacheHeaderControl.php' in the 'craft/config' folder.

Example for overwriting the default expiration:

```
