簡體   English   中英

nginx proxy_cache 無法緩存

[英]nginx proxy_cache unable to cache

我嘗試使用 Nginx 進行內容緩存但不工作

那是我的 app.test.conf 文件

 proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_cache:10m max_size=10g 
                 inactive=60m use_temp_path=off;
                 

server {
        listen 80;
        listen [::]:80;

        root /var/www/app.test/html;
        index index.php;
        
        server_name app.test;
        
        proxy_cache my_cache;

        location / {
    
                
           try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }

    }

最后我能夠解決它,閱讀開始使用 fastcgi_cache 而不是 proxy_cache

當然我還添加了一些東西

fastcgi_cache my_cache;
fastcgi_cache_valid 200 302 60m;

和結果

fastcgi_cache_path  /var/cache/nginx/
                 keys_zone=my_cache:60m 
                 levels=1:2 
                 inactive=3h 
                 max_size=100m;

server {
        listen 80;
        listen [::]:80;

        root /var/www/app.test/html;
        index index.php;
        server_name app.test;
    
       error_log /var/log/nginx/$host.log;
    
       fastcgi_cache my_cache;
       fastcgi_cache_valid 200 302 60m;

       fastcgi_cache_valid 404 1m;
    

    

        
    location / {
   
         try_files $uri $uri/ /index.php?$query_string;
       
     }


    location ~ \.php$ {
     
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
     }

    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM