wordpress - Leverage browser caching not working - Htaccess & mod_expires Active -
i´ve been trying leverage browser cache quite while , have no idea problem. tried several methods activate it, nothing works...
the site running on namecheap hosting. contacted support , asked if mod_expires module active , according customer support is...
this code i´ve been using:
# start --- browser cache control # turn on expires , set default 0 expiresactive on expiresdefault a0 # set caching on media files 1 year (forever?) <filesmatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$"> expiresdefault a29030400 header append cache-control "public" </filesmatch> # set caching on media files 1 week <filesmatch "\.(gif|jpg|jpeg|png|swf)$"> expiresdefault a604800 header append cache-control "public" </filesmatch> # set 2 hour caching on commonly updated files <filesmatch "\.(xml|txt|html|js|css)$"> expiresdefault a7200 header append cache-control "proxy-revalidate" </filesmatch> # force no caching dynamic files <filesmatch "\.(php|cgi|pl|htm)$"> expiresactive off header set cache-control "private, no-cache, no-store, proxy-revalidate, no-transform" header set pragma "no-cache" </filesmatch> # end --- browser cache control
i tried other methods like:
## expires caching ## <ifmodule mod_expires.c> expiresactive on expiresbytype image/jpg "access 1 year" expiresbytype image/jpeg "access 1 year" expiresbytype image/gif "access 1 year" expiresbytype image/png "access 1 year" expiresbytype text/css "access 1 month" expiresbytype text/html "access 1 month" expiresbytype application/pdf "access 1 month" expiresbytype text/x-javascript "access 1 month" expiresbytype application/x-shockwave-flash "access 1 month" expiresbytype image/x-icon "access 1 year" expiresdefault "access 1 month" </ifmodule> ## expires caching ##
it nice if has idea wrong code ;)
i have resolved it in short:- resolved issue have enable expires_module module. linux can easy that.
azureuser@azure: sudo a2enmod expires enabling module expires. activate new configuration, need run: service apache2 restart azureuser@azure: sudo service apache2 restart [....] restarting web server: . ok
in deep:-
people seeing among other things need leverage browser caching, think 1 stop fix , thats add following .htaccess file:
expiresactive on expiresdefault "access plus 5 seconds" expiresbytype image/x-icon "access plus 2592000 seconds" expiresbytype image/jpeg "access plus 2592000 seconds" expiresbytype image/png "access plus 2592000 seconds" expiresbytype image/gif "access plus 2592000 seconds" expiresbytype application/x-shockwave-flash "access plus 2592000 seconds" expiresbytype text/css "access plus 604800 seconds" expiresbytype text/javascript "access plus 216000 seconds" expiresbytype application/javascript "access plus 216000 seconds" expiresbytype application/x-javascript "access plus 216000 seconds" expiresbytype text/html "access plus 600 seconds" expiresbytype application/xhtml+xml "access plus 600 seconds"
this seems , go metrics tool, re-analyse , see issue still prevalent.. spend next while trying figure out why not working , website still in dog house metrics wise. fear not issue not website 1 speak, server one. if using debian server quick fix have been looking for: log dedicated/vps , issue following command check see modules loaded on server, looking expires_module in list
azureuser@azure: sudo apachectl -m loaded modules: core_module (static) log_config_module (static) logio_module (static) version_module (static) mpm_prefork_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) php5_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) ssl_module (shared) status_module (shared) syntax ok
so there no sign of expires_module in list, next have install it
azureuser@azure: sudo a2enmod expires enabling module expires. activate new configuration, need run: service apache2 restart azureuser@azure: sudo service apache2 restart [....] restarting web server: . ok
head metrics , rerun test, sure add code specified above htaccess also. should have passed leverage browser caching test.
my website speed 85, trying resolve leverage cache resolved this. screenshot:- http://prntscr.com/fcuutv
Comments
Post a Comment