Question

I'm already over 3 hours of searching for a working browser caching functionality. I've tried over 20 HTaccess scripts, half of them resulting in a 500-error. Yet, via PageSpeed and GTMetrix, they still shout I should use browser caching, which means the HTaccess rules are ignored or not working.

By saying I've tried over 20 scripts, I think I can say at least one of them is working, but Since Google and GTMetrix say there was no browser caching, the script in .htaccess is ignored.

So I'm really wondering what could be it. It might be a server related problem? I'm running Ubuntu 12.04

Perhaps a specific php mod isn't loaded. Since in the code you always write <ifModule mod_expires.c> I thought, perhaps I needed the mod_expires. So I created a php file with the following code

<?php
    print_r(apache_get_modules());
?>

To see if mod_expires was enabled.. but it isn't. Exactly 24 mods were enabled, but not expires.

For those interested, these are the mods that are enabled, printed via the above script

Array ( [0] => core [1] =>
mod_log_config [2] =>
mod_logio [3] =>
prefork [4] =>
http_core [5] => 
mod_so [6] => 
mod_alias [7] => 
mod_auth_basic [8] => 
mod_authn_file [9] => 
mod_authz_default [10] => 
mod_authz_groupfile [11] => 
mod_authz_host [12] => 
mod_authz_user [13] => 
mod_autoindex [14] => 
mod_cgi [15] => 
mod_deflate [16] => 
mod_dir [17] => 
mod_env [18] => 
mod_mime [19] => 
mod_negotiation [20] => 
mod_php5 [21] => 
mod_reqtimeout [22] => 
mod_rewrite [23] => 
mod_setenvif [24] => mod_status )

Who can tell me if mod_expires is a must have for browser caching via .htaccess and how to get it working?

Thanks!

Was it helpful?

Solution

To answer my own question:

If you find yourself in a problem that all the htaccess scripts aren't working, try the above PHP code (3 lines) and find out if mod_expires is active on your server.

If not: Check this tutorial how to enable it! :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top