I am very new in Apache Configuration and caching.
I want set some headers in Apache (eg max-age, min-fresh, last modified etc).
Have checked Modules are there and there installed and loaded....
Have edited httpd.conf and re-started the same after making some changes regarding caching headers.
e.g.
<FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 year"
</FilesMatch>`
Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2012 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch>
Even tried different other things and when I tried to check for response on client side (MSIE and Mozilla). None of these headers came in response.
LoadModule foo_module modules/mod_foo.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
# ......
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule cgi_module modules/mod_cgi.so
and these are located on specific directory ....
(shows the desired output -- ls /etc/httpd/modules | egrep "headers|expire")
These are the only changes which I have done. Please let me know if I m missing something or doing something wrong,
Not sure why your config is not working as expected, however....
A better solution than omitting the Etag and last-modified from the response is to cut the if-none-match and if-modified_since from the request.
I would expect the ExpiresDefault settings to have the desired effect, however I've only used the ExpiresByType settings (these work for me). Your first block should also include the appropriate Cache-control headers (max-age).
Why the second block?
Did you check your error_log at startup?
The expires might not be working because the mime types are not set. Your showing mime_magic_module modules/mod_mime_magic.so as loaded but you could still use the AddType then use ExpiresByType instead of FilesMatch. Also you should set Pragma "public" before the Cache-Control "Public".
Here is a bullet proof expires, gzip, FileEtag and cache control that I use. It works on most Apache configurations.