Nginx服务器(未显示更改) - 删除缓存?

时间:2015-07-25 01:44:13

标签: php css nginx server digital-ocean

我正在Nginx上运行Laravel站点(Ubuntu)(不是虚拟盒子)。当我对css文件或任何文件进行更改时,我无法立即看到更改。我已尝试将sendfile从on更改为off,如此链接所示:

How to clear the cache of nginx?

我找不到Nginx缓存文件来删除缓存。许多网站建议转到“path / to / cache”文件夹,但我找不到它:

https://www.nginx.com/blog/nginx-caching-guide/

无论如何,我不相信我设置了任何类型的代理缓存或任何东西。我能找到我的缓存的任何想法,所以我可以删除它们吗?就此而言,我希望在这里做正确的事情吗?谢谢你提前回答。

这是我的测试服务器块的样子:

server { 
        # secure website with username and password in htpasswd file
       auth_basic "closed website";
       auth_basic_user_file /tmp/.htpasswd.txt;

        listen (myip) default_server;
        listen [::]:83 default_server ipv6only=on;


        root /var/www/test/(sitefolder);
        index index.php index.html index.htm;

        # Make site accessible
        server_name (myiphere);

location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
}

这是我的真实站点服务器块的样子:

server {
        # secure website with username and password in htpasswd file
        auth_basic "closed website";
        auth_basic_user_file /tmp/.htpasswd.txt;

        listen (myip) default_server;
        listen [::]:81 default_server ipv6only=on;

        root /var/www/(mysite)/public;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name (myip);

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

 location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

1 个答案:

答案 0 :(得分:0)

首先,css是客户端缓存的东西,而不是服务器。您应该清除浏览器的缓存以查看您的CSS更改。此外,浏览器缓存是css和javascript开发中的常见问题。幸运的是,你可以利用elixir,它附带laravel 5.1,以防止浏览器缓存你的资产。

访问文档以获取有关laravel elixir的更多信息。

http://laravel.com/docs/5.1/elixir#versioning-and-cache-busting

其次,laravel为我们提供了一个方便的命令来清除服务器的缓存:

... put :backlog, id: feature.id feature.reload expect(feature.deploy_status).to eq('backlog')

更新:

php artisan cache:clear