问题标签 [expires-header]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
713 浏览

jboss - 为 JS/图像设置过期标头

请帮助为 JS/Images/CSS 等文件设置 Expiry Header

服务器:Linux 应用服务器:Jboss

我在互联网上得到了一些例子来使用 .htaccess 文件实现类似的事情,但不清楚。

0 投票
1 回答
2403 浏览

html5boilerplate - 为静态内容添加过期标头 google recaptcha

我使用 Yslow 测试了我的网站,它指出

有 7 个静态组件没有遥远的到期日期。

https://www.google.com/recaptcha/api.js?onload=myCallBack&render=explicit&hl=en http://www.searchanise.com/widgets/v1.0/init.js

现在我已经看到 HTML5Boilerplate 项目有一个很好的 .htaccess 文件和示例,但我看不出它如何应用于我网站上的发现。

0 投票
2 回答
356 浏览

php - Http 标头:过期

Expires 标头的工作方式相当简单。它们告诉浏览器将文件存储在缓存中多长时间,这样后续的页面查看和访问就不必再次下载文件。您认为 Expires Headers 不会在第一次访问时提高页面速度是正确的,因为该访问者必须第一次下载所有文件。使用 Expires 标头有助于增加回访者的加载时间

当我运行下面的代码然后在浏览器中检查标题时,到期日期真的让我感到困惑 -> Expires:Thu, 19 Nov 1981 08:52:00 GMT <-,因为我在几分钟前创建了这个文件。你能告诉我这是什么意思吗?

谢谢!

0 投票
0 回答
2053 浏览

caching - Nginx is not setting Expires and Cache-Control headers

Chromium Dev Tools complain about all the resources being "explicitly non cacheable", although I'm explicitly adding the relevant directives in my config.

I have this file in /etc/nginx/sites-enabled/, which is included by the main config:

Here are the headers:
Request

Response

I see that a Pragma: no-cache and a Cache-Control: no-cache is present, but I didn't add it for sure. Is Chrome adding it?

0 投票
1 回答
290 浏览

gzip - Gzipping 和设置过期 Google Cloud Storage 上的标头

我正在使用以下命令将文件上传到 Google 的云存储。这些命令 gzip HTML、CSS 和 JS,然后在 CSS、JS 和图像上将过期标头设置为 6 个月。

是否可以将其简化为一两个命令?

0 投票
1 回答
3353 浏览

caching - 通过 nginx 使用浏览器缓存

我在我的/etc/nginx/nginx.conf debian 服务器中添加了 expires 但它没有出现在网站文件的标题中:

这是我的nginx.conf

有人看到有什么问题吗?我根本不是专家,我只是从教程中复制过去...

谢谢

0 投票
1 回答
1459 浏览

javascript - nginx with expires on javascript files (dynamically generated by PHP)

I have a problem with expires headers on javascript files which are generated by PHP..

The website has two types of javascript files. One part is static javascript files and one part is dynamically generated by PHP.

conf without expires headers

Here no expires headers are added to the .js files (All files return HTTP 200)

conf with expires headers

When adding a location for .js files then all dynamically generated files return HTTP 404

How to handle both the static and dynamically generated .js files with expires headers?

All dynamically genereated javascript files are named *-php.js

File structure

PHP routing

0 投票
1 回答
457 浏览

.htaccess - 为每个目录设置一个 .htaccess 文件

我正在处理我域上的多个子域。我刚刚完成了一项工作,并想为这个特定的子域指定缓存标头。我不希望其他子域也启用缓存标头,只是我完成的单个子域。

因此,过期标头应该适用于子域 A,但不适用于子域 B 和 C。

我不知道如何实现这一点,也找不到类似的问题。

我当前的 .htaccess 文件

0 投票
0 回答
2418 浏览

node.js - 带有express的Node js如何为静态文件启用缓存

我已经尝试了所有的可能性。以下是我的响应标头

但它仍然没有返回 304 状态。如果我在 Firefox 中刷新命令刷新,它会再次使用 200 响应代码下载该图像。我不希望如果用户单击命令刷新它应该返回 304 状态。而不是下载新文件,它应该从浏览器缓存中获取。

以下是我的nodejs代码

谁能指导我如何启用完美缓存。提前致谢..

0 投票
1 回答
1125 浏览

.htaccess - 使用 htaccess 设置静态资源的过期时间

刚刚知道为静态资源设置到期日期可以让您的网站快速运行并提高排名。

我的问题是:

  1. 浏览器是否检查静态资源的创建日期?

  2. 如果我在 1 个月之前对 CSS 进行更改,服务器是否会发送新副本并且浏览器会刷新其缓存?

这是我添加到 htaccess 的代码: