eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.46k stars 314 forks source link

Setting Cache-Control header #252

Open mattstudio opened 8 years ago

mattstudio commented 8 years ago

The default cache-control is set to max-age=604800 (one week). How can I change this? (Apart from editing file.py)

Ideally, my html pages would have a max-age=0, while images, css, and javascript would have a max-age= a month or something.

Any ideas how this could be done? Is there a way to specify this on each page? Or in some sort of plugin?

sergadin commented 8 years ago

+1

It seems that one can create a plugin like that

def preDeployFile(file):
    cache_expiration = 60 * 60 # One hour
    if file.path.endswith('.html'):
        file.cache_control = cache_expiration