Pregunta

Tengo Yslow complemento instalado

text alt

Cuando los cheques mi solicitud en Yslow I get Añadir Expira cabeceras , que no sé

text alt

Me buscó preguntas relevantes en SO y Google me encontré con este método apropiado

<?
    header("Expires:".gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
    header("Cache-Control: no-cache");
    header("Pragma: no-cache");
    ob_start();
    session_cache_limiter('public');
    session_start();
?>
<html>

Pero todavía me muestra mismo

Como soy novato no sé mucho acerca de .htaccess

Por favor, ayuda a mejorar el rendimiento de aplicaciones

Gracias de antemano

Wazzy

¿Fue útil?

Solución

Eso sólo lo establecerá por el contenido de su página y no cosas como imágenes y archivos CSS, me di cuenta en la captura de pantalla que dice 42 archivos, presumiblemente, estos son sus imágenes, CSS, JS, etc.

Pruebe esto en su archivo .htaccess, tenga en cuenta que esto sólo funcionará si tiene mod_expires y habilitado mod_headers en Apache:

<ifModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 1 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
  ExpiresByType application/javascript "access plus 216000 seconds"  
</ifModule>

<ifModule mod_headers.c>
  <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </filesMatch>
  <filesMatch "\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
  <filesMatch "\\.(js)$">
    Header set Cache-Control "max-age=216000, private"
  </filesMatch>
  <filesMatch "\\.(xml|txt)$">
    Header set Cache-Control "max-age=216000, public, must-revalidate"
  </filesMatch>
  <filesMatch "\\.(html|htm|php)$">
    Header set Cache-Control "max-age=1, private, must-revalidate"
  </filesMatch>
</ifModule>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top