Expirace cache

Místo pro dotazy, které se netýkají phpBB, ale mají něco společného s webovými technologiemi, skriptovacími jazyky anebo překládáním.
Odpovědět
Uživatelský avatar
Difadon
Příspěvky: 242
Registrován: úte 05. lis 2013 21:33:22
Bydliště: Špindlerův Mlýn
Kontaktovat uživatele:

Expirace cache

Příspěvek od Difadon » ned 09. lis 2014 0:43:47

Ahoj,

Dneska jsem zkoumal co vlastně znamená gzip komprese. Zjistil jsem, že je dobré ji mít aktivovanou pro zrychlení načítání. Zároveň jsem ale narazil na zajímavou úpravu .htaccess. Myslíte, že má smysl tu úpravu používat?

Kód: Vybrat vše

# ---------------------------------------------------------
# Proper MIME type for all files
# CZ: Normalizace MIME typu pro vsechny soubory
# ------------------------------------------------------------
 
# JavaScript
#   Normalize to standard type (it's sniffed in IE anyways)
#   tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript         js
 
# Audio
AddType audio/ogg                      oga ogg
AddType audio/mp4                      m4a
 
# Video
AddType video/ogg                      ogv
AddType video/mp4                      mp4 m4v
AddType video/webm                     webm
 
# SVG
#   Required for svg webfonts on iPad
#   twitter.com/FontSquirrel/status/14855840545
AddType     image/svg+xml              svg svgz
AddEncoding gzip                       svgz
 
# Webfonts
AddType application/vnd.ms-fontobject  eot
AddType application/x-font-ttf         ttf ttc
AddType font/opentype                  otf
AddType application/x-font-woff        woff
 
# Assorted types
AddType image/x-icon                        ico
AddType image/webp                          webp
AddType text/cache-manifest                 appcache manifest
AddType text/x-component                    htc
AddType application/x-chrome-extension      crx
AddType application/x-opera-extension       oex
AddType application/x-xpinstall             xpi
AddType application/octet-stream            safariextz
AddType application/x-web-app-manifest+json webapp
AddType text/x-vcard                        vcf
 
# ----------------------------------------------------------------
# Expires headers (for better cache control)
# CZ: Hlavicky pro kontrolu nastaveni expirace
# ----------------------------------------------------------------
 
# These are pretty far-future expires headers.
# They assume you control versioning with cachebusting
# CZ: Toto jsou hlavicky s velmi dlouhou dobou expirace
# CZ: Predpokladaji ze vyuzivate cachebusting techniku
 
# Additionally, consider that outdated proxies may miscache
# CZ: Nektere zastarale proxy mohou cachovat chybne
#   www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
 
<IfModule mod_expires.c>
  ExpiresActive on
 
# Perhaps better to whitelist expires rules? Perhaps.
  ExpiresDefault                          "access plus 1 month"
 
# 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 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpg                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"
  ExpiresByType video/ogg                 "access plus 1 month"
  ExpiresByType audio/ogg                 "access plus 1 month"
  ExpiresByType video/mp4                 "access plus 1 month"
  ExpiresByType video/webm                "access plus 1 month"
 
# HTC files  (css3pie)
  ExpiresByType text/x-component          "access plus 1 month"
 
# Webfonts
  ExpiresByType application/x-font-ttf    "access plus 1 month"
  ExpiresByType font/opentype             "access plus 1 month"
  ExpiresByType application/x-font-woff   "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
 
# CSS and JavaScript
  ExpiresByType text/css                  "access plus 1 year"
  ExpiresByType application/javascript    "access plus 1 year"
 
</IfModule>
 
# ---------------------------------------------------------------
# ETag removal
# CZ: Odstraneni ETagu
# ---------------------------------------------------------------
 
# FileETag None is not enough for every server.
# FileETag None neni dostacujici pro vsechny servery.
 
<IfModule mod_headers.c>
  Header unset ETag
</IfModule>
 
# Since we're sending far-future expires, we don't need ETags for
# static content.
# CZ: Protoze nase expirace je daleko v budoucnu nepotrebujeme odesilat ETag pro staticky obsah.
# http://developer.yahoo.com/performance/rules.html#etags
 
FileETag None
A pokud to správně chápu, tak pokud upravím:

Kód: Vybrat vše

"access plus 1 month"
třeba na:

Kód: Vybrat vše

"access plus 2 month"
tak to znamená, že expiraci (tedy prohlížeč bude znovu stahovat data) až po 2 měsících?

Tomas93
Příspěvky: 4
Registrován: pon 19. kvě 2014 12:36:00

Re: Expirace cache

Příspěvek od Tomas93 » čtv 22. led 2015 21:11:39

Podle mého názoru ano. :-)

Odpovědět