Apache mod expires expires_by_type syntax example

8 views
Skip to first unread message

Nat Juchems

unread,
Jun 14, 2019, 5:51:57 PM6/14/19
to Puppet Users
Hey all -

I was getting pretty frustrated with this due to my own lack of understanding.  The best resource I could find on this was:


Under the apache::mod::expires heading it says this:

expires_by_type: Describes a set of MIME content-type and their expiration times. Valid options: An array of Hashes, with each Hash's key a valid MIME content-type (i.e. 'text/json') and its value following valid interval syntax. Default: undef.

For me that was only a hint.  I had to find other examples with similar descriptions and actual examples to put it all together.  I am hoping that posting this here will make it easier for someone else in the future:

class { '::apache::mod::expires':
      expires_by_type => {
        'image/gif'                         => 'access plus 12 hours',
        'image/png'                       => 'access plus 12 hours',
        'image/jpeg'                       => 'access plus 12 hours',
        'image/svg+xml'                 => 'access plus 12 hours',
        'image/x-icon'                     => 'access plus 2 weeks',
        'application/javascript'        => 'access plus 1 hour',
        'text/css'                             => 'access plus 1 hour',
        'image/vnd.microsoft.icon' => 'access plus 2 weeks',
      }
    }

Getting the MIME types figured out was a minor annoyance in comparison.

I am not setting this forth as a complete list or recommended settings.  Just as an in the wild syntax example.

I added it to my blog too, just in case...

Reply all
Reply to author
Forward
0 new messages