Puppet Class: apache::mod::pagespeed

Defined in:
manifests/mod/pagespeed.pp

Summary

Installs and manages mod_pagespeed, which is a Google module that rewrites web pages to reduce latency and bandwidth. This module does *not* manage the software repositories needed to automatically install the mod-pagespeed-stable package. The module does however require that the package be installed, or be installable using the system's default package provider. You should ensure that this pre-requisite is met or declaring `apache::mod::pagespeed` will cause the puppet run to fail.

Overview

Note:

Verify that your system is compatible with the latest Google Pagespeed requirements.

Although this apache module requires the mod-pagespeed-stable package, Puppet does not manage the software repositories required to automatically install the package. If you declare this class when the package is either not installed or not available to your package manager, your Puppet run will fail.

Examples:

class { 'apache::mod::pagespeed':
  inherit_vhost_config          => 'on',
  filter_xhtml                  => false,
  cache_path                    => '/var/cache/mod_pagespeed/',
  log_dir                       => '/var/log/pagespeed',
  memache_servers               => [],
  rewrite_level                 => 'CoreFilters',
  disable_filters               => [],
  enable_filters                => [],
  forbid_filters                => [],
  rewrite_deadline_per_flush_ms => 10,
  additional_domains            => undef,
  file_cache_size_kb            => 102400,
  file_cache_clean_interval_ms  => 3600000,
  lru_cache_per_process         => 1024,
  lru_cache_byte_limit          => 16384,
  css_flatten_max_bytes         => 2048,
  css_inline_max_bytes          => 2048,
  css_image_inline_max_bytes    => 2048,
  image_inline_max_bytes        => 2048,
  js_inline_max_bytes           => 2048,
  css_outline_min_bytes         => 3000,
  js_outline_min_bytes          => 3000,
  inode_limit                   => 500000,
  image_max_rewrites_at_once    => 8,
  num_rewrite_threads           => 4,
  num_expensive_rewrite_threads => 4,
  collect_statistics            => 'on',
  statistics_logging            => 'on',
  allow_view_stats              => [],
  allow_pagespeed_console       => [],
  allow_pagespeed_message       => [],
  message_buffer_size           => 100000,
  additional_configuration      => { }
}

Parameters:

  • inherit_vhost_config (String) (defaults to: 'on')

    Whether or not to inherit the vhost config

  • filter_xhtml (Boolean) (defaults to: false)

    Whether to filter by xhtml

  • cache_path (Stdlib::Absolutepath) (defaults to: '/var/cache/mod_pagespeed/')

    Where to cache any files

  • log_dir (Stdlib::Absolutepath) (defaults to: '/var/log/pagespeed')

    The log directory

  • memcache_servers (Array) (defaults to: [])
  • rewrite_level (String) (defaults to: 'CoreFilters')

    The inbuilt filter level to be used. Can be ‘PassThrough`, `CoreFilters` or `OptimizeForBandwidth`.

  • disable_filters (Array) (defaults to: [])

    An array of filters that you wish to disable

  • enable_filters (Array) (defaults to: [])

    An array of filters that you wish to enable

  • forbid_filters (Array) (defaults to: [])

    An array of filters that you wish to forbid

  • rewrite_deadline_per_flush_ms (Integer) (defaults to: 10)

    How long to wait after attempting to rewrite an uncache/expired resource.

  • additional_domains (Optional[String]) (defaults to: undef)

    Any additional domains that PageSpeed should optimize resources from.

  • file_cache_size_kb (Integer) (defaults to: 102400)

    The maximum size of the cache

  • file_cache_clean_interval_ms (Integer) (defaults to: 3600000)

    The interval between which the cache is cleaned

  • lru_cache_per_process (Integer) (defaults to: 1024)

    The amount of memory dedcated to each process

  • lru_cache_byte_limit (Integer) (defaults to: 16384)

    How large a cache entry the cache will accept

  • css_flatten_max_bytes (Integer) (defaults to: 2048)

    The maximum size in bytes of the flattened CSS

  • css_inline_max_bytes (Integer) (defaults to: 2048)

    The maximum size in bytes of any image that will be inlined into CSS

  • css_image_inline_max_bytes (Integer) (defaults to: 2048)

    The maximum size in bytes of any image that will be inlined into an HTML file

  • image_inline_max_bytes (Integer) (defaults to: 2048)

    The maximum size in bytes of any inlined CSS file

  • js_inline_max_bytes (Integer) (defaults to: 2048)

    The maximum size in bytes of any inlined JavaScript file

  • css_outline_min_bytes (Integer) (defaults to: 3000)

    The minimum size in bytes for a CSS file to qualify as an outline

  • js_outline_min_bytes (Integer) (defaults to: 3000)

    The minimum size in bytes for a JavaScript file to qualify as an outline

  • inode_limit (Integer) (defaults to: 500000)

    The file cache inode limit

  • image_max_rewrites_at_once (Integer) (defaults to: 8)

    The maximum number of images to optimize concurrently

  • num_rewrite_threads (Integer) (defaults to: 4)

    The amount of threads to use for rewrite at one time These threads are used for short, latency-sensitive work.

  • num_expensive_rewrite_threads (Integer) (defaults to: 4)

    The amount of threads to use for rewrite at one time These threads are used for full optimization.

  • collect_statistics (String) (defaults to: 'on')

    Whether to collect cross-process statistics

  • statistics_logging (String) (defaults to: 'on')

    Whether graphs should be drawn from collected statistics

  • allow_view_stats (Array) (defaults to: [])

    What sources should be allowed to view the resultant graph

  • allow_pagespeed_console (Array) (defaults to: [])

    What sources to draw the graphs from

  • allow_pagespeed_message (Array) (defaults to: [])
  • message_buffer_size (Integer) (defaults to: 100000)

    The amount of bytes to allocate as a buffer to hold recent log messages

  • additional_configuration (Variant[Array, Hash]) (defaults to: {})

    Any additional configuration no included as it’s own option

  • package_ensure (Optional[String]) (defaults to: undef)

See Also:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'manifests/mod/pagespeed.pp', line 157

class apache::mod::pagespeed (
  String $inherit_vhost_config                   = 'on',
  Boolean $filter_xhtml                          = false,
  Stdlib::Absolutepath $cache_path               = '/var/cache/mod_pagespeed/',
  Stdlib::Absolutepath $log_dir                  = '/var/log/pagespeed',
  Array $memcache_servers                        = [],
  String $rewrite_level                          = 'CoreFilters',
  Array $disable_filters                         = [],
  Array $enable_filters                          = [],
  Array $forbid_filters                          = [],
  Integer $rewrite_deadline_per_flush_ms         = 10,
  Optional[String] $additional_domains           = undef,
  Integer $file_cache_size_kb                    = 102400,
  Integer $file_cache_clean_interval_ms          = 3600000,
  Integer $lru_cache_per_process                 = 1024,
  Integer $lru_cache_byte_limit                  = 16384,
  Integer $css_flatten_max_bytes                 = 2048,
  Integer $css_inline_max_bytes                  = 2048,
  Integer $css_image_inline_max_bytes            = 2048,
  Integer $image_inline_max_bytes                = 2048,
  Integer $js_inline_max_bytes                   = 2048,
  Integer $css_outline_min_bytes                 = 3000,
  Integer $js_outline_min_bytes                  = 3000,
  Integer $inode_limit                           = 500000,
  Integer $image_max_rewrites_at_once            = 8,
  Integer $num_rewrite_threads                   = 4,
  Integer $num_expensive_rewrite_threads         = 4,
  String $collect_statistics                     = 'on',
  String $statistics_logging                     = 'on',
  Array $allow_view_stats                        = [],
  Array $allow_pagespeed_console                 = [],
  Array $allow_pagespeed_message                 = [],
  Integer $message_buffer_size                   = 100000,
  Variant[Array, Hash] $additional_configuration = {},
  Optional[String] $package_ensure               = undef,
) {
  include apache

  apache::mod { 'pagespeed':
    lib            => 'mod_pagespeed_ap24.so',
    package_ensure => $package_ensure,
  }

  $parameters = {
    'inherit_vhost_config'          => $inherit_vhost_config,
    'filter_xhtml'                  => $filter_xhtml,
    'cache_path'                    => $cache_path,
    'log_dir'                       => $log_dir,
    'memcache_servers'              => $memcache_servers,
    'rewrite_level'                 => $rewrite_level,
    'disable_filters'               => $disable_filters,
    'enable_filters'                => $enable_filters,
    'forbid_filters'                => $forbid_filters,
    'rewrite_deadline_per_flush_ms' => $rewrite_deadline_per_flush_ms,
    'additional_domains'            => $additional_domains,
    'file_cache_size_kb'            => $file_cache_size_kb,
    'file_cache_clean_interval_ms'  => $file_cache_clean_interval_ms,
    'lru_cache_per_process'         => $lru_cache_per_process,
    'lru_cache_byte_limit'          => $lru_cache_byte_limit,
    'css_flatten_max_bytes'         => $css_flatten_max_bytes,
    'css_inline_max_bytes'          => $css_inline_max_bytes,
    'css_image_inline_max_bytes'    => $css_image_inline_max_bytes,
    'image_inline_max_bytes'        => $image_inline_max_bytes,
    'js_inline_max_bytes'           => $js_inline_max_bytes,
    'css_outline_min_bytes'         => $css_outline_min_bytes,
    'js_outline_min_bytes'          => $js_outline_min_bytes,
    'inode_limit'                   => $inode_limit,
    'image_max_rewrites_at_once'    => $image_max_rewrites_at_once,
    'num_rewrite_threads'           => $num_rewrite_threads,
    'num_expensive_rewrite_threads' => $num_expensive_rewrite_threads,
    'collect_statistics'            => $collect_statistics,
    'allow_view_stats'              => $allow_view_stats,
    'statistics_logging'            => $statistics_logging,
    'allow_pagespeed_console'       => $allow_pagespeed_console,
    'message_buffer_size'           => $message_buffer_size,
    'allow_pagespeed_message'       => $allow_pagespeed_message,
    'additional_configuration'      => $additional_configuration,
  }

  file { 'pagespeed.conf':
    ensure  => file,
    path    => "${apache::mod_dir}/pagespeed.conf",
    mode    => $apache::file_mode,
    content => epp('apache/mod/pagespeed.conf.epp', $parameters),
    require => Exec["mkdir ${apache::mod_dir}"],
    before  => File[$apache::mod_dir],
    notify  => Class['apache::service'],
  }
}