Forum Moderators: phranque
Apache/2.2.22 Debian) before, and I cannot tell if my noobishness is to blame or if it is misconfigured. There are 5 static components without a far-future expiration date [and] misconfigured ETags.(this list does not include the php-generated html document itself, but all images and css files)
<IfModule ...> clauses. phpinfo();: core mod_log_config mod_logio mod_version prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dav mod_dav_svn mod_authz_svn mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_passenger mod_perl mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_ssl mod_status
Is there a way to configure expires headers without apache/.htaccess?
AddDefaultCharset utf-8
<IfModule deflate_module>
# Enable compression for the following file types.
AddOutputFilterByType \
DEFLATE \
application/javascript \
text/css \
text/html \
text/javascript \
text/plain \
text/xml\
text/php
</IfModule>
# allow access from all domains for webfonts
<FilesMatch ".(ttf|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
# Cache Files 1 Day
<FilesMatch "\.(jpg|jpeg|png|gif|swf|js)$">
<IfModule mod_headers.c>
Header set Cache-Control "max-age=86400, public"
</IfModule>
</FilesMatch>
ErrorDocument 404 /error.php
ErrorDocument 403 /error.php
ErrorDocument 500 /error.php
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
#LoadModule expires_module modules/mod_expires.so
#AddModule mod_expires.so
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 days"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule> mod_expires module is what controls Expires and Cache-Control HTTP headers, but you have it two ways, each with a different setting. <IfModule mod_headers.c>
Header set Cache-Control "max-age=86400, public"
</IfModule> mod_expires allows one month for images. I need to check but pretty sure that mod_headers lets you customize headers but not set Cache-Control. (?) I have not seen DEFLATE done quite that way before, but it isn't something I look at every day, it may well be an alternative I'm not familiar with. Usually seen them as: AddOutputFilterByType DEFLATE text/plain text/html
AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript AddOutputFilterByType \
DEFLATE \
application/javascript \
AddOutputFilterByType filter[;filter...] MIME-type [MIME-type] ... all others throw a 500 error as soon as i remove the <IfModule...> clauses
Because of certain problems discussed below, this directive is deprecated. The same functionality is available using mod_filter.
although that friend definitely has some experience with web development, i can't shake the feeling that some things are seriously misconfigured there.
ExpiresActive On <IfModule mod_expires.c>
ExpiresActive On
</IfModule>
=> no error no error, but no caching either, according to Yslow and gtmetrics.
AddModule Directive
This directive has been removed in current versions of the server. See LoadModule
LoadModule Directive
Context: server config, virtual host
but if i enclose that line in an IfModule clause, there's no error.
can i load a module via .htaccess?