EZ Zoom Full-Page Cache mit Magento unter nginx verwenden
Magento-Shops lassen sich durch den Einsatz des Zoom Full-Page Caches erheblich beschleunigen, da sich bei gecachten Seiten der komplette PHP-MySQL-Stack umgehen läßt. Seitenladezeiten von 100 - 200ms sind so keine Seltenheit mehr.
Der Zoom Full-Page Cache läßt sich natürlich auch mit nginx nutzen. Wir stellen Ihnen dazu schon eine fertige Konfiguration zur Verfügung. Um diese zu übernehmen, gehen Sie in ISPConfig zum Optionen-Reiter Ihrer Website und platzieren Sie den Cursor im (leeren) nginx-Direktiven-Feld:

Rechts neben dem Feld finden Sie einige vorgefertigte Konfigurationen. Klicken Sie auf den Link [Magento + EZ Zoom Full Page Cache], um die dazugehörige nginx-Konfiguration in das nginx-Direktiven-Feld zu übernehmen:

Die Konfiguration sollte jetzt in das nginx-Direktiven-Feld übernommen worden sein:

Stellen Sie sicher, daß in den Zeilen...
set $code default; # This should match your MAGE_RUN_CODE
... und...
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
... der korrekte Store-Code Ihres Online-Shops eingetragen ist (Standardwert: default).
Speichern Sie die Einstellungen; nach ca. ein bis zwei Minuten sollten die Änderungen übernommen worden und der Cache funktionsfähig sein, sofern Sie das Zoom Full-Page Cache-Modul in Magento aktivert haben.
Hier ist die komplette Konfiguration, die im nginx-Direktiven-Feld stehen sollte:
set $ua '';
set $zget /zget;
# User Agent theme overrides will be cached to their own sub-directories
# if ( $http_user_agent ~ iphone ){
# set $ua '/default/default/iphone';
# }
set $mzi /ZOOM_INDEX;
set $code default; # This should match your MAGE_RUN_CODE
# Multi-language stores use different codes on the same domain. Use the 'store' cookie to detect this
# if ($cookie_store) { set $code $cookie_store; }
set $zoombase /var/zoom/$code$ua;
set $zoomuri $zoombase$uri; # This will be pages without toolbars (products, CMS, etc)
set $zoomuriget $zoomuri$zget; # Here is our initial category variable
# By default, we will always check for the first page of a potential category page
set $p 1;
# Initialize toolbar state according to Zoom cookies.
set $dir $cookie_zoom_dir;
set $limit $cookie_zoom_limit;
set $mode $cookie_zoom_mode;
set $order $cookie_zoom_order;
set $zoomg $zoomuriget;
# Initialize layered navigation variables
set $cat "";
set $price "";
# Over-ride toolbar state with GET variables (if they exist)
if ($arg_p) {
set $p $arg_p;
}
if ($arg_dir) {
set $dir $arg_dir;
}
if ($arg_limit) {
set $limit $arg_limit;
}
if ($arg_mode) {
set $mode $arg_mode;
}
if ($arg_order) {
set $order $arg_order;
}
# Layered navigation will be appended in alphabetical order to the final string
if ($arg_cat) {
set $cat /cat/$arg_cat;
}
if ($arg_price) {
set $price /price/$arg_price;
}
set $control &dir=$dir&limit=$limit&mode=$mode&order=$order;
# If there is no given toolbar state, look for symlink of the default state (at the given page)
if ($control = "&dir=&limit=&mode=&order=") {
set $zoomg $zoomg/p/$p;
}
# Otherwise, construct complete cache filename (this requires normalized URL for consistent hits)
if ($zoomg = $zoomuriget) {
set $zoomg $zoomg/p/$p/dir/$dir/limit/$limit/mode/$mode/order/$order$cat$price;
}
# A fix to redirect the index page to the proper file
#if ($request_uri = /) {
# set $zoomuri $zoomuri$mzi;
#}
# Append the "ZOOM_INDEX" to the file category path
set $zoomg $zoomg$mzi;
# Now clean the filename of irregular characters
if ($zoomg ~ (.*)/price/([0-9]+),([0-9]+)(.*)) {
set $zoomg $1/price/$2%2C$3$4;
}
client_max_body_size 100M;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $zoomuri $zoomg $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file /var/www/example.com/.htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*\.php)/ $1 last;
}
location /skin/m/ {
rewrite ^/skin/m/([0-9]+)(/.*\.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location @php { ##merge##
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
}