Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Douglas Fernandess

Problema Aproveitar cache do navegador php html

Recommended Posts

Os seguintes recursos armazenáveis em cache têm uma vida útil de atualização curta. Especifique uma expiração de pelo menos uma semana no futuro para os seguintes recursos:

 

Ele pede pra coloca uma data de expiração seria neh?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Certo.

 

Mantendo o cachê pelo php

 

 

 

 

<?php
header("Cache-Control: store, cache, no-revalidate");
header("Cache-Control: post-check=1, pre-check=1", false);
header("Pragma: cache");
?>

Via htaccess (acho que pra seu caso é a melhor saída)

 

 

 

 

# 1 ANO
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 SEMANA
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DIAS
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 1 MINUTO
<FilesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>

Compartilhar este post


Link para o post
Compartilhar em outros sites

sim tenho isso

 

 

 
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
Options -Indexes
<IfModule mod_deflate.c>
# Insert filter
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE text/html
 
SetOutputFilter DEFLATE
 
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
 
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
 
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
 
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Então Douglas, sinto muito, aqui funciona perfeitamente, tanto localhost quanto publicado :yes:

 

Ao menos que tenha bugado o seu servidor :skull:

 

Está testando online ou localhost ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

seria online e localhost kkkkkkkkkkk porque é um servidor interno aqui, servidor caseiro..



coloquei esse que adaptei conforme olhei no seu e não deu nenhum erro...

 

 

 
<IfModule mod_headers.c>
 
# 1 ANO = 29030400s = Nunca expira
<filesMatch "\\.(ico|pdf|flv)$"> 
Header set Cache-Control "max-age=29030400, public"
</filesMatch>
 
# 1 SEMANA = 604800
<filesMatch "\\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
 
# 2 DIAS = 172800
<filesMatch "\\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, public"
</filesMatch>
 
# 1 MINUTO = 60
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=60, public"
</filesMatch>
 
</IfModule>


Como eu posso fazer o teste para ver se vai funciona ou não?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.