php7.2 + nginx + 内存缓存。未检索到内存缓存密码子目录中的 style.css 和 script.js

php7.2 + nginx + memcache. style.css and script.js in memcache passworded subdirectory not retrieved

我在 memcache 目录上设置了密码,index.php 运行正常。但它的样式不正确。我调查了一下,起初我在 nginx 日志中收到 "access denied" 错误。然后我添加了这些行

     location ~ \.js {
        add_header Content-Type application/javascript;
        add_header Content-Encoding gzip;
        expires 365d;
     }
     location ~ \.css {
        add_header Content-Type text/css;
        add_header Content-Encoding gzip;
        expires 30d;
     }

并开始在我的浏览器中显示空白 script.js 和 style.css。 nginx日志没有错误。 然后我检查了子目录权限。

    drwxr-xr-x 5 www-data www-data  4096 сен  1  2016 Public/
    drwxr-xr-x 2 www-data www-data 4096 сен  1  2016 Images/
    drwxr-xr-x 2 www-data www-data 4096 сен  1  2016 Scripts/
    drwxr-xr-x 2 www-data www-data 4096 сен  1  2016 Styles/
    -rw-r--r-- 1 www-data www-data 3673 май 30  2012 Style.css
    -rw-r--r-- 1 www-data www-data 10422 янв 27  2012 Script.js

所以没有任何效果。如何渲染这些文件?

    location ^~ /memcache/ {
142
143
144                 auth_basic "Restricted";
145                 auth_basic_user_file /etc/nginx/.htpasswd;
146
147
148
149                 location ~ \.js {
150                 add_header Content-Type application/javascript;
151                 add_header Content-Encoding gzip;
152                 expires 30d;
153                 }
154                 location ~ \.css {
155                 add_header Content-Type text/css;
156                 add_header Content-Encoding gzip;
157                 expires 30d;
158                 }
159
160
161
162
163
164         location ~ \.php$ {
165
166
167          fastcgi_split_path_info ^(.+\.php)(/.+)$;
168          fastcgi_pass  unix:/var/run/php/php7.2-fpm.sock;
169          fastcgi_index index.php;
170          include fastcgi_params;
171          fastcgi_intercept_errors        on;
172          fastcgi_ignore_client_abort     on;
173          fastcgi_connect_timeout 600;
174          fastcgi_send_timeout 180;
175          fastcgi_read_timeout 600s;
176          fastcgi_buffer_size 128k;
177          fastcgi_buffers 4 256k;
178          fastcgi_busy_buffers_size 256k;
179          fastcgi_temp_file_write_size 256k;
180 }

location ~ \.js {
add_header Content-Type application/javascript;
add_header Content-Encoding gzip;    # removing this line worked like magic
expires 30d;
}
location ~ \.css {
add_header Content-Type text/css;
add_header Content-Encoding gzip;   #and this one too
expires 30d;
}

我忘了网站的其余部分使用了 gzipped css 和 js。我没有计划保护 phpMemcacheAdmin 文件夹。