Autor Zpráva
diro
Profil
Ydravim
potreboval by som poradit ako dostat do .htaccess Cache-Control: max-age= a Expires
poskusal som uy mnoystvo kombinacii, ale bud to nefunguje alebo mi da : Internal Server Error
neviete mi niekto poradit co robim zle, pripadne ci je potrebne este nieco spustit na Apache?
Potrebujem to na nastavenie Cashe. Dakujem za akukolvek pomoc.
Diro

pripajam ukazku mojho .htaccess:

ErrorDocument 404 "http://www.xxx.de/404.html"

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* ? [F,L]

RewriteCond  %{HTTP_HOST} ^78\.47\.xxx\.xxx
RewriteRule  (.*) http://www.xxx.de/$1 [R=301,L]

RewriteCond  %{HTTP_HOST} ^xxx\.de
RewriteRule  (.*) http://www.xxx.de/$1 [R=301,L]

RewriteCond  %{HTTP_HOST} xxx\.de/
RewriteRule  (.*) http://www.xxx.de/ [R=301,L]

RewriteCond %{HTTP_HOST} !^www.xxx.de$ [NC] 
RewriteRule .? http://www.xxx.de%{REQUEST_URI} [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.html($|\ |\?)
RewriteRule ^ /%1 [R=301,L]

<IfModule mod_deflate.c>
    #The following line is enough for .js and .css
    AddOutputFilter DEFLATE js css
    AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css   application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html

    #The following lines are to avoid bugs with some browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive on
 
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(js|css|xml|gz)$">
        Header append Vary Accept-Encoding
    </FilesMatch>
    <FilesMatch "\.(ico|jpe?g|png|gif|swf)$">
        Header set Cache-Control "public"
    </FilesMatch>
    <FilesMatch "\.(css)$">
        Header set Cache-Control "public"
    </FilesMatch>
    <FilesMatch "\.(js)$">
        Header set Cache-Control "private"
    </FilesMatch>
    <FilesMatch "\.(x?html?|php)$">
        Header set Cache-Control "private, must-revalidate"
    </FilesMatch>
</IfModule>
Davex
Profil
V Apache musí být zapnutý modul mod_expires a nastavení ExpiresByType by pak mělo začít fungovat. Vícenásobné nastavení různých hlaviček Cache-Control pomocí konfigurační volby Header set je nesmysl.
diro
Profil
Davex:
Ahoj Davex,
podarilo s ami to spustit, pomocou prikazov a2enmod expires a a2enmod headers, aj som restartoval Apache, dal som tam novy .htaccess ale hlasi mi to chybu 500 Internal Server Error
Nevies co je tam za chybu, pripajam novy .htaccess:
Dakujem za pomoc :-)
Diro

[pre]
ErrorDocument 404 "www.xxx.de/404.html"

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]

RewriteCond %{HTTP_HOST} ^78\.47\.xxx\.xxx
RewriteRule (.*) www.x.de/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^xxx\.de
RewriteRule (.*) www.xxx.de/$1 [R=301,L]

RewriteCond %{HTTP_HOST} xxx\.de/
RewriteRule (.*) www.xxx.de [R=301,L]

RewriteCond %{HTTP_HOST} !^www.xxx.de$ [NC]
RewriteRule .? www.xxx.de%{REQUEST_URI} [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.html($|\ |\?)
RewriteRule ^ /%1 [R=301,L]


<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html

#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

#### Expires By Type
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 60 seconds"
ExpiresByType image/x-icon "access plus 29030400 seconds"
ExpiresByType image/jpeg "access plus 29030400 seconds"
ExpiresByType image/jpg "access plus 29030400 seconds"
ExpiresByType image/png "access plus 29030400 seconds"
ExpiresByType image/gif "access plus 29030400 seconds"
ExpiresByType application/x-shockwave-flash "access plus 29030400 seconds"
ExpiresByType text/css "access plus 2592000 seconds"
ExpiresByType text/javascript "access plus 2592000 seconds"
ExpiresByType application/x-javascript "access plus 2592000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</IfModule>

#### Cache-Control
<ifModule mod_headers.c>
# Turn on Expires and set default expires to 3 days
ExpiresActive On
ExpiresDefault A259200

# Set up caching on media files for 1 month
<filesMatch ".(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
ExpiresDefault A2419200
Header append Cache-Control "public"
</filesMatch>

# Set up 2 Hour caching on commonly updated files
<filesMatch ".(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "private, must-revalidate"
</filesMatch>

# Force no caching for dynamic files
<filesMatch ".(php|cgi|pl|htm)$">
ExpiresDefault A0
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
</filesMatch>
</ifModule>

#### ETags
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None
Davex
Profil
Formálně je konfigurace v pořádku. V chybovém logu Apache by mělo být víc podrobností k chybě.

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0