我正在使用Nginx和HTTPD开发基于Angular的SPA;我最近意识到在Nginx错误日志中记录了一些未解析的AngularJS表达式:
2016/03/24 10:47:53 [error] 63879#0: *2639 open() "/var/www/mysite/assets/css/png/{{ client.logo }}_bw.png" failed (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: example.com, request: "GET /css/png/{{%20client.logo%20}}_bw.png HTTP/1.1", host: "www.example.com", referrer: "https://www.example.com/my-page"
2016/03/24 10:48:34 [error] 63879#0: *2789 open() "/var/www/mysite/assets/css/png/{{ src }}-small.png" failed (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: example.com, request: "GET /css/png/{{%20src%20}}-small.png HTTP/1.1", host: "www.example.com", referrer: "https://www.example.com/"
2016/03/24 10:48:37 [error] 63879#0: *2813 open() "/var/www/mysite/assets/css/png/{{ src }}-small.png" failed (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: example.com, request: "GET /assets/css/png/%7B%7B%20src%20%7D%7D-small.png HTTP/1.1", host: "www.example.com", referrer: "https://www.example.com/my-page"
在网站上正确评估表达式是正常显示的图像,但确实可能有短暂的处理时间。如何在评估这些表达式之前阻止Nginx记录这些表达式?
答案 0 :(得分:0)
在应用程序中显示图像时需要使用ng-src
- 否则浏览器会将未解析表达式的请求发送到服务器。
<强>错误:强>
<img src="assets/css/png/{{ client.logo }}_bw.png" />
从右:强>
<img ng-src="assets/css/png/{{ client.logo }}_bw.png" />