如何在Nginx上配置ETag [英] How to configure ETag on Nginx

查看:391
本文介绍了如何在Nginx上配置ETag的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Nginx用作网络服务器,并希望实现一种浏览器缓存方法,以便用户将静态的未更改文件的副本保留在本地,并且仅下载更改的文件.提议之一是使用文件时间戳来找出已更改的文件并仅刷新它们,但是在我的情况下这是不可能的,因为在每次新部署之后,都会创建整个Web应用程序的新版本并创建所有文件的时间戳.改变.

I'm using Nginx as a webserver and want to implement a browser caching method so that the users keep copies of static unchanged files locally and download only changed files. One of the propositions was to use the files timestamp to figure out the changed files and refresh them only, but this is not possible in my case since after every new deploy a new version of the whole web application is created and all the files' timestamps change.

我对ETag标头进行了一些研究,这似乎是一个很好的解决方案,但是我发现Etags尚未得到Nginx的正式支持.

I researched a little about the ETag header, and it seemed as a pretty good solution, but I found out that Etags are not officially supported by Nginx yet.

有什么方法可以在Nginx上实现Etag或任何替代解决方案?

Are there any way of implementing the Etags on Nginx or any alternative solutions?

推荐答案

升级您的Nginx.

Syntax:     etag on | off;
Default:    etag on;

Context:    http, server, location

This directive appeared in version 1.3.3.

Enables or disables automatic generation of the "ETag" response header field for static resources.

来源: http://nginx.org/en/docs/http/ngx_http_core_module.html#etag

这篇关于如何在Nginx上配置ETag的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆