|
12 | 12 | # - Debian: /var/cache/apache2/mod_cache_disk |
13 | 13 | # - FreeBSD: /var/cache/mod_cache_disk |
14 | 14 | # - Red Hat, Apache 2.4: /var/cache/httpd/proxy |
15 | | -# - Red Hat, Apache 2.2: /var/cache/mod_proxy |
16 | 15 | # |
17 | 16 | # @param cache_enable |
18 | 17 | # Defines an array of directories to cache, the default is none |
19 | | -# |
20 | | -# @param cache_ignore_headers |
21 | | -# Specifies HTTP header(s) that should not be stored in the cache. |
22 | | -# |
| 18 | + |
23 | 19 | # @param cache_dir_length |
24 | 20 | # The number of characters in subdirectory names |
25 | 21 | # |
26 | 22 | # @param cache_dir_levels |
27 | 23 | # The number of levels of subdirectories in the cache. |
28 | 24 | # |
29 | | -# @param cache_default_expire |
30 | | -# The default duration to cache a document when no expiry date is specified. |
31 | | -# |
32 | | -# @param cache_max_expire |
33 | | -# The maximum time in seconds to cache a document |
34 | | -# |
35 | | -# @param cache_ignore_no_lastmod |
36 | | -# Ignore the fact that a response has no Last Modified header. |
37 | | -# |
38 | | -# @param cache_header |
39 | | -# Add an X-Cache header to the response. |
40 | | -# |
41 | | -# @param cache_lock |
42 | | -# Enable the thundering herd lock. |
43 | | -# |
44 | | -# @param cache_ignore_cache_control |
45 | | -# Ignore request to not serve cached content to client |
46 | | -# |
47 | 25 | # @param cache_max_filesize |
48 | 26 | # The maximum size (in bytes) of a document to be placed in the cache |
49 | 27 | # |
| 28 | +# @param cache_ignore_headers |
| 29 | +# DEPRECATED Ignore request to not serve cached content to client (included for compatibility reasons to support disk_cache) |
| 30 | +# |
| 31 | +# @param configuration_file_name |
| 32 | +# DEPRECATED Name of module configuration file (used for the compatibility layer for disk_cache) |
| 33 | +# |
50 | 34 | # @note |
51 | 35 | # Apache 2.2, mod_disk_cache installed. On Apache 2.4, mod_cache_disk installed. |
52 | 36 | # |
53 | | -# @see https://httpd.apache.org/docs/2.2/mod/mod_disk_cache.html for additional documentation on version 2.2. |
54 | | -# |
55 | 37 | # @see https://httpd.apache.org/docs/2.4/mod/mod_cache_disk.html for additional documentation on version 2.4. |
56 | 38 | # |
57 | 39 | class apache::mod::cache_disk ( |
58 | | - $cache_root = undef, |
59 | | - Array[String] $cache_enable = [], |
60 | | - Optional[String] $cache_ignore_headers = undef, |
61 | | - Optional[Integer] $cache_dir_length = undef, |
62 | | - Optional[Integer] $cache_dir_levels = undef, |
63 | | - Optional[Integer] $cache_default_expire = undef, |
64 | | - Optional[Integer] $cache_max_expire = undef, |
65 | | - Optional[Enum['Off', 'On']] $cache_ignore_no_lastmod = undef, |
66 | | - Optional[Enum['off', 'on']] $cache_header = undef, |
67 | | - Optional[Enum['off', 'on']] $cache_lock = undef, |
68 | | - Optional[Enum['Off', 'On']] $cache_ignore_cache_control = undef, |
69 | | - Optional[Integer] $cache_max_filesize = undef, |
| 40 | + Optional[String] $cache_root = undef, |
| 41 | + Array[String] $cache_enable = [], |
| 42 | + Optional[Integer] $cache_dir_length = undef, |
| 43 | + Optional[Integer] $cache_dir_levels = undef, |
| 44 | + Optional[Integer] $cache_max_filesize = undef, |
| 45 | + Optional[String] $cache_ignore_headers = undef, |
| 46 | + Optional[String] $configuration_file_name = undef, |
70 | 47 | ) { |
71 | 48 | include apache |
72 | | - if $cache_root { |
73 | | - $_cache_root = $cache_root |
| 49 | + |
| 50 | + if $cache_ignore_headers { |
| 51 | + deprecation( |
| 52 | + 'apache::mod::cache_disk', |
| 53 | + 'The parameter cache_ignore_headers is deprecated. Please use apache::mod::cache::cache_ignore_headers instead.' |
| 54 | + ) |
74 | 55 | } |
75 | | - elsif versioncmp($apache::apache_version, '2.4') >= 0 { |
76 | | - $_module_name = 'cache_disk' |
77 | | - $_cache_root = $::osfamily ? { |
| 56 | + |
| 57 | + $_cache_root = $cache_root ? { |
| 58 | + undef => $facts['os']['family'] ? { |
78 | 59 | 'debian' => '/var/cache/apache2/mod_cache_disk', |
79 | 60 | 'redhat' => '/var/cache/httpd/proxy', |
80 | 61 | 'freebsd' => '/var/cache/mod_cache_disk', |
81 | | - } |
| 62 | + }, |
| 63 | + default => $cache_root, |
82 | 64 | } |
83 | | - else { |
84 | | - $_module_name = 'disk_cache' |
85 | | - $_cache_root = $::osfamily ? { |
86 | | - 'debian' => '/var/cache/apache2/mod_disk_cache', |
87 | | - 'redhat' => '/var/cache/mod_proxy', |
88 | | - 'freebsd' => '/var/cache/mod_disk_cache', |
89 | | - } |
| 65 | + $_configuration_file_name = $configuration_file_name ? { |
| 66 | + undef => 'cache_disk.conf', |
| 67 | + default => $configuration_file_name |
90 | 68 | } |
91 | | - $_configuration_file_name = "${_module_name}.conf" |
92 | | - $_class_name = "::apache::mod::${_module_name}" |
| 69 | + $_class_name = 'apache::mod::cache_disk' |
93 | 70 |
|
94 | | - apache::mod { $_module_name: } |
| 71 | + apache::mod { 'cache_disk': } |
95 | 72 |
|
96 | | - Class['::apache::mod::cache'] -> Class[$_class_name] |
| 73 | + Class['apache::mod::cache'] -> Class[$_class_name] |
97 | 74 |
|
98 | | - # Template uses |
99 | | - # - $_cache_root |
100 | | - # - $cache_enable |
101 | | - # - $cache_dir_length |
102 | | - # - $cache_ignore_headers |
103 | | - # - $cache_dir_length |
104 | | - # - $cache_dir_levels |
105 | | - # - $cache_default_expire |
106 | | - # - $cache_max_expire |
107 | | - # - $cache_ignore_no_lastmod |
108 | | - # - $cache_header |
109 | | - # - $cache_lock |
110 | | - # - $cache_ignore_cache_control |
111 | | - # - $cache_max_filesize |
112 | 75 | file { $_configuration_file_name: |
113 | 76 | ensure => file, |
114 | 77 | path => "${apache::mod_dir}/${_configuration_file_name}", |
115 | 78 | mode => $apache::file_mode, |
116 | | - content => template('apache/mod/cache_disk.conf.erb'), |
| 79 | + content => epp('apache/mod/cache_disk.conf.epp', { |
| 80 | + cache_root => $_cache_root, |
| 81 | + cache_enable => $cache_enable, |
| 82 | + cache_dir_length => $cache_dir_length, |
| 83 | + cache_dir_levels => $cache_dir_levels, |
| 84 | + cache_max_filesize => $cache_max_filesize, |
| 85 | + cache_ignore_headers => $cache_ignore_headers, |
| 86 | + }), |
117 | 87 | require => Exec["mkdir ${apache::mod_dir}"], |
118 | 88 | before => File[$apache::mod_dir], |
119 | 89 | notify => Class['apache::service'], |
|
0 commit comments