加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

ubuntu – 阻止已删除文件的多个请求

发布时间:2020-12-13 21:11:55 所属栏目:Nginx 来源:网络整理
导读:我在Nginx上运行Wordpress的服务器上托管了一个JavaScript文件.我删除了该文件,但仍有多个来自多个引用的请求.这些引用来自不同的URL和IP地址. 有很多请求,我想阻止它们,因为它似乎影响我的服务器的性能. 有没有办法可以阻止这些请求? 最佳答案 我想,当您明

我在Nginx上运行Wordpress的服务器上托管了一个JavaScript文件.我删除了该文件,但仍有多个来自多个引用的请求.这些引用来自不同的URL和IP地址.

有很多请求,我想阻止它们,因为它似乎影响我的服务器的性能.

有没有办法可以阻止这些请求?

最佳答案
我想,当您明确配置nginx时旧的javascript的位置不再有效时,你将获得性能提升,因为nginx不再需要检查文件系统,并且当你发送410错误时它不需要发送404错误页面:

location /path/to/script.js {
return 410 ; 
}

HTTP状态代码410:已消失

The requested resource is no longer available at the server and no
forwarding address is known. This condition is expected to be
considered permanent. Clients with link editing capabilities SHOULD
delete references to the Request-URI after user approval. If the
server does not know,or has no facility to determine,whether or not
the condition is permanent,the status code 404 (Not Found) SHOULD be
used instead. This response is cacheable unless indicated otherwise.

The 410 response is primarily intended to assist the task of web
maintenance by notifying the recipient that the resource is
intentionally unavailable and that the server owners desire that
remote links to that resource be removed. Such an event is common for
limited-time,promotional services and for resources belonging to
individuals no longer working at the server’s site. It is not
necessary to mark all permanently unavailable resources as “gone” or
to keep the mark for any length of time — that is left to the
discretion of the server owner.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读