test.conf

proxy_cache_path cache levels=1:2 keys_zone=my_cache:10m;

server {
listen 80;
server_name testyhl.com; location / {
proxy_cache my_cache;
proxy_pass http://127.0.0.1:8888;
proxy_set_header Host $host;
}
}

server.js

const http = require('http')
const fs = require('fs') const wait = (seconds) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, seconds * 1000)
})
} http.createServer((request, response) => {
console.log('requres come', request.url) if (request.url === '/') {
const html = fs.readFileSync('test.html', 'utf-8') response.writeHead(200, {
'Content-Type': 'text/html'
}) response.end(html)
} if (request.url === '/data') {
response.writeHead(200, {
'Cache-Control': 'max-age=5, s-maxage=20, private',
    'Vary': 'X-Test-Cache'
})
wait(2).then(() => response.end('success'))
} }).listen(8888) console.log('server listening on 8888')

test.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>This is content, and data is: <span id="data"></span></div>
</body>
<script>
fetch('/data').then((res) => {
return res.text()
}).then((text) => {
document.getElementById('data').innerText = text
})
</script>
</html>

nginx-cache的更多相关文章

  1. nginx cache的玩法

      一.简介 Nginx版本从0.7.48开始,支持了类似Squid的缓存功能.这个缓存是把URL及相关组合当做Key,用Md5算法对Key进行哈希,得到硬盘上对应的哈希目录路径,从而将缓存内容保存在 ...

  2. 查看nginx cache命中率

    一.在http header上增加命中显示 nginx提供了$upstream_cache_status这个变量来显示缓存的状态,我们可以在配置中添加一个http头来显示这一状态,达到类似squid的 ...

  3. NGINX Cache Management (.imh nginx)

    In this article, we will explore the various NGINX cache configuration options, and tips on tweaking ...

  4. FastDFS_v5.05+nginx+cache集群安装配置手册

    转载请出自出处:http://www.cnblogs.com/hd3013779515/ 1.FastDFS简单介绍 FastDFS是由淘宝的余庆先生所开发,是一个轻量级.高性能的开源分布式文件系统, ...

  5. 使用nginx cache缓存网站数据实践

    Nginx本身就有缓存功能,能够缓存静态对象,比如图片.CSS.JS等内容直接缓存到本地,下次访问相同对象时,直接从缓存即可,无需访问后端静态服务器以及存储存储服务器,可以替代squid功能. 1   ...

  6. Nginx Cache中$request_filename(转)

    对于Nginx的$request_filename变量指的就是请求的资源路径.在原先 OpenCDN节点端配置里面是这样的. location ~ .*\.(png|html|htm|ico|jpg| ...

  7. varnish/squid/nginx cache 有什么不同?

    SQUID 是功能最全面的,但是架构太老,性能不咋的Varnish 是内存缓存,速度一流,但是内存缓存也限制了其容量,缓存页面和图片一般是挺好的Nginx 本来是反向代理/web服务器,用了插件可以做 ...

  8. web cache server方案比较:varnish、squid、nginx

    linux运维中,web cache server方案的部署是一个很重要的环节,选择也有很多种比如:varnish.squid.nginx.下面就对当下常用的这几个web cache server做一 ...

  9. 死磕nginx系列--使用nginx做cache服务

    配置文件 nginx.conf 主配置文件 worker_processes 1; events { worker_connections 1024; } http { include mime.ty ...

  10. [svc]tomcat目录结构/虚拟主机/nginx反向代理cache配置

    tomcat目录文件 /usr/local/tomcat/bin/catalina.sh stop sleep 3 /usr/local/tomcat/bin/catalina.sh start to ...

随机推荐

  1. 集成Log4Net到自己的Unity工程

    需要使用的插件库说明: Loxodon Framework Log4NetVersion: 1.0.0© 2016, Clark Yang=============================== ...

  2. JS高级---函数声明和函数表达式的区别

    函数声明和函数表达式的区别 多用函数表达式 var ff=function(){}; //函数声明 // // if(true){ // function f1() { // console.log( ...

  3. jdk动态代理底层实现

    一.代理设计模式 代理设计模式是Java常用的设计模式之一. 特点: 01.委托类和代理类有共同的接口或者父类: 02.代理类负责为委托类处理消息,并将消息转发给委托类: 03.委托类和代理类对象通常 ...

  4. 阿里巴巴手册之-Arrays.asList()数组转集合的问题

    转载来源:https://blog.csdn.net/qq_36443497/article/details/79663663?utm_source=blogxgwz9 在使用工具类Arrays.as ...

  5. 生产环境实践:Cana实现MySQL到ES实时同步

    注:由于文章篇幅有限,完整文档可扫下面二维码免费获取,更有深受好评的大数据实战精英+架构师好课等着你. 速点链接加入高手战队:http://www.dajiangtai.com/course/112. ...

  6. Python入门2 —— 变量

    一:问号三连 1.什么是变量? 变 指的是事物的状态是可以发生变化的 量 指的是记录事物的状态 2.为什么要有变量? 为了让计算机像人一样去记录事物的状态 3.怎么用变量? 先定义 后引用 二:变量的 ...

  7. 查看Oracle的SID的方式

    1  使用组合键“Win + R”打开运行对话框,在输入框中输入 regedit 并回车打开“注册表编辑器”. 2   在“注册表编辑器”对话框,依次展开 HKEY_LOCAL_MACHINE\SOF ...

  8. 【转载】Win7下如何使用GCC编译器

    转自:http://jingyan.baidu.com/article/c275f6bacc0126e33c756771.html 双击GCC安装包,mingw-get-setup.exe,点击Ins ...

  9. THINKPHP 模板上传图片--后台接收图片

    模板 {extend name="public/base" /} {block name="body"} <div class="row&quo ...

  10. springboot @ComponentScan注解

    @ComponentScan 告诉Spring从哪里找到bean. 如果你的其他包都在@SpringBootApplication注解的启动类所在的包及其下级包,则你什么都不用做,SpringBoot ...