2016-04-25 12 views
0

Ich habe Arbeits Rahmen 1.12 basierte Website zend mit nginxCache Zend Framework Homepage auf nginx

ich auf Windows 7 Professional installiert WNMP von Windows zu testen, nginx, MariaDB, php7

Ich möchte Homepage Cache, ist localhost oder localhost/ die index.php mit index.php

ähnlich Urls http://localhost/conference/sessions/date/2015-04/12/page/1 Konferenz ruft intern - Controller-Sitzungen - Aktionsanforderung params Datum und Seite mit den jeweiligen Werten

Ich will nach Hause Seite zwischenzuspeichern, aber ich habe gesucht, aber nichts Konkretes zur Verfügung

Hier ist meine nginx.conf, die ohne Caching funktioniert

hier ist das, was ich in meinem nginx.conf haben

worker_processes 1; 
error_log logs/error.log; 
pid  logs/nginx.pid; 

events { 
    # Max value 16384 
    worker_connections 8192; 
    # Accept multiple connections 
    multi_accept on; 
} 

# Settings that affect all server blocks 
http { 
    include php_processes.conf; 
    include  mime.types; 
    default_type application/octet-stream; 
    access_log logs/access.log; 
fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k; 

    sendfile on; 

    keepalive_timeout 65; 
    ssl_session_timeout 10m; 
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1 SSLv3; 
    ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS; 
    ssl_prefer_server_ciphers on; 
    gzip on; 
    # http server 

# Begin HTTP Server 
server { 
    listen 80; # IPv4 
    server_name localhost; 

    ## Parametrization using hostname of access and log filenames. 
    access_log logs/localhost_access.log; 
    error_log logs/localhost_error.log; 

    ## Root and index files. 
    root html; 
    index index.php index.html index.htm; 
    ## If no favicon exists return a 204 (no content error). 
    location = /favicon.ico { 
     try_files $uri =204; 
     log_not_found off; 
     access_log off; 
    } 

    ## Don't log robots.txt requests. 
    location = /robots.txt { 
     allow all; 
     log_not_found off; 
     access_log off; 
    } 
    ## Try the requested URI as files before handling it to PHP. 
    location/{ 
     ## Regular PHP processing. 
     location ~ \.php$ { 
      try_files $uri =404; 
      fastcgi_pass php_processes; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include  fastcgi_params; 
     } 
     ## Static files 
     location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ { 
      expires max; 
      log_not_found off; 
      ## No need to bleed constant updates. Send the all shebang in one 
      ## fell swoop. 
      tcp_nodelay off; 
      ## Set the OS file cache. 
      open_file_cache max=1000 inactive=120s; 
      open_file_cache_valid 45s; 
      open_file_cache_min_uses 2; 
      open_file_cache_errors off; 
     } 
     ## Keep a tab on the 'big' static files. 
     location ~* ^.+\.(?:ogg|pdf|pptx?)$ { 
      expires 30d; 
      ## No need to bleed constant updates. Send the all shebang in one 
      ## fell swoop. 
      tcp_nodelay off; 
     } 
     try_files $uri $uri/ @missing; 
    } #/location 
    location @missing { 
     rewrite (.*) /index.php; 
    } 
} 

Bitte helfen.

+0

Suche immer noch im Internet auf der Suche nach Hilfe; –

+0

Verwendung von ZendFramework 1.18 '# Beginne HTTP-Server fastcgi_cache_path/home/k47/nginx/Cache-Ebenen = 1: 2 keys_zone = MYHOMEPAGE: 100m inaktiv = 60m; fastcgi_cache_key "$ schema $ request_method $ host $ request_uri $ cookie_abgap $ cookie_PHPSESSID $ cookie__ga $ cookie__gat"; fastcgi_cache_valid 200 302 1m; Standort/{ \t \t Menge $ no_cache 0; \t \t fastcgi_cache_bypass $ no_cache; \t \t fastcgi_no_cache $ no_cache; \t \t \t \t \t fastcgi_cache MYHOMEPAGE; \t \t fastcgi_cache_valid 200 5m; \t \t add_header X-Proxy-Cache $ upstream_cache_status; \t \t 'Immer noch" MISS " –

Antwort

0

Hinzugefügt Unter http note - zwei Unterstrichen hinzufügen (__), wenn Sie beginnt mit und Unterstrich (_)

fastcgi_cache_path /home/k47/cache/nginx levels=1:2 keys_zone=MYHOMEPAGE:100m inactive=60m; 
fastcgi_cache_key "$scheme$request_method$host$request_method$query_string$request_uri$cookie_one$cookie_two$cookie__ga$cookie__gat"; 
fastcgi_cache_use_stale error timeout invalid_header http_500; 
fastcgi_ignore_headers Cache-Control Expires Set-Cookie; 
fastcgi_cache_valid 200 302 1m; 

Unter Server-Cookie ein Flag/Variable, die verwendet werden können, um festzustellen, ob wir Caching müssen oder nicht ich habe andere URLs verwendet zwischenzuspeichern und nicht cachen mit ähnlichen regex

set $no_cache 1; 
if ($request_uri ~* "^/$") 
{ 
    set $no_cache 0; 
} 

dann schließlich unter Lage {} ich beginne mit

fastcgi_cache_bypass $no_cache; 
fastcgi_no_cache $no_cache;   
fastcgi_cache MYHOMEPAGE; 
fastcgi_cache_valid 200 1m; 
add_header X-Proxy-Cache $upstream_cache_status; 
add_header cache-control 'public, max-age=500';