2014-12-01 30 views
0

現在我正在嘗試在我的.conf文件中。如果我這樣做,沒有任何圖片顯示出來。當使用流星與MUP和NGINX時,我應該如何設置我的緩存?

location ~* \.(jpg|jpeg|png|gif|ico)$ { 
    expires 365d; 
} 

location ~* \.(pdf)$ { 
    expires 30d; 
} 

我已經對SO望着這個問題(https://stackoverflow.com/a/18039576/582309)和我使用MUP擁有它並沒有解決這個問題。

我也嘗試將根路徑包含到MUP創建的構建目錄中,但這也不起作用。此外,我從緩存中刪除了CSS和JS,因爲如果這些頁面無法正常工作,頁面將無法加載,我不確定Meteor是否已經在考慮緩存這些文件。

location ~* \.(jpg|jpeg|png|gif|ico)$ { 
    root /opt/give/app/programs/web.browser; //tried many combinations of the path 
    expires 365d; 
} 

location ~* \.(pdf)$ { 
    expires 30d; 
} 

這裏是.conf文件

Sites.conf GIST

https://gist.github.com/c316/9552ecdc8107334fc55d

位置具體要點其餘的GIST

https://gist.github.com/c316/4917d95cbfddd3e181ad

+0

對此有幫助嗎? https://github.com/meteorinaction/appendices/blob/master/configuration/nginx/nginxsite.conf – Stephan 2014-12-02 15:45:09

+0

@Stephan是你的根路徑MUP的路徑或者是你存儲你的git repo或者是其他東西? – JoshJoe 2014-12-02 15:54:27

+0

另外,我正在運行meteor而不是僅僅根URL或/所以我不知道這是否會影響緩存。 – JoshJoe 2014-12-02 15:58:51

回答

0

原來那緩存我的圖像字體和其他公共資產,我真的需要這樣做。

已經有這個頂部

location /give { 
    proxy_pass http://trashmountainGive/app_name; 
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_set_header Host $http_host; 

    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forward-Proto http; 
    proxy_set_header X-Nginx-Proxy true; 

    proxy_redirect off; 

    #Added everything below here 

    location /give/images { 
     alias /opt/app_name/app/programs/web.browser/app/images; 
     access_log off; 
     expires max; 
    } 

    location /give/fonts { 
     alias /opt/app_name/app/programs/web.browser/app/fonts; 
     access_log off; 
     expires max; 
    } 
} 

結帳本文

http://nginx.com/blog/nginx-nodejs-websockets-socketio/

向下滾動到 「什麼靜態文件?」

相關問題