La velocidad de carga de la web, es un punto muy importante a la hora del posicionamiento en los buscadores.
Esta velocidad de carga se puede mejorar en algo activando la caché del navegador y la compresión GZIP de los archivos, que nos permitirá reducir el ancho de banda y reducir tiempos de carga.
Vamos a ver el código que se podría utilizar en un fichero .htaccess para activar lo comentado anteriormente, además de poner una fecha de expiración para nuestros headers, evitando así la carga simultánea del mismo archivo.
El código es el siguiente:
## BEGIN EXPIRES CACHING ## <IfModule mod_expires.c> ExpiresActive on # Perhaps better to whitelist expires rules? Perhaps. ExpiresDefault "access plus 1 year" # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) ExpiresByType text/cache-manifest "access plus 0 seconds" # Your document html ExpiresByType text/html "access plus 0 seconds" # Data ExpiresByType text/xml "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType application/json "access plus 0 seconds" # Feed ExpiresByType application/rss+xml "access plus 1 hour" ExpiresByType application/atom+xml "access plus 1 hour" # Favicon (cannot be renamed) ExpiresByType image/x-icon "access plus 1 week" # Media: images, video, audio ExpiresByType image/gif "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/webp "access plus 1 year" ExpiresByType audio/ogg "access plus 1 year" ExpiresByType video/ogg "access plus 1 year" ExpiresByType video/mp4 "access plus 1 year" ExpiresByType video/webm "access plus 1 year" # HTC files (css3pie) ExpiresByType text/x-component "access plus 1 year" # Webfonts ExpiresByType application/font-ttf "access plus 1 year" ExpiresByType font/* "access plus 1 year" ExpiresByType application/font-woff "access plus 1 year" ExpiresByType application/font-woff2 "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType application/vnd.ms-fontobject "access plus 1 year" # CSS and JavaScript ExpiresByType text/css "access plus 1 year" ExpiresByType type/javascript "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" <IfModule mod_headers.c> Header append Cache-Control "public" <FilesMatch ".(js|css|xml|gz|html)$"> Header append Vary: Accept-Encoding </FilesMatch> </IfModule> </IfModule> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/font AddOutputFilterByType DEFLATE application/font-truetype AddOutputFilterByType DEFLATE application/font-ttf AddOutputFilterByType DEFLATE application/font-otf AddOutputFilterByType DEFLATE application/font-opentype AddOutputFilterByType DEFLATE application/font-woff AddOutputFilterByType DEFLATE application/font-woff2 AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE font/woff AddOutputFilterByType DEFLATE font/woff2 </IfModule> ## END EXPIRES CACHING ##