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>

最新文章

  1. STL set使用例子
  2. Atitit 为什么网络会有延时 电路交换与分组交换的区别
  3. PHP学习之常量
  4. winform app.config文件的动态配置
  5. [vijos P1880]ファーラの力
  6. Eclipse 3.5使用dropins的插件安装方式
  7. weblogic11g重置控制台管理员用户名/密码
  8. 关于getpw系列函数返回的静态区域
  9. php static 关键字在 函数中的用法
  10. 在2015中使用V12版本的ReportView控件,会导致winform窗体不能正常打开
  11. Windows下效率必备软件
  12. oracle多种导入导出数据方法
  13. Jsoup使用教程
  14. Appium入门示例(Java)
  15. ES6--浅析Promise内部结构
  16. Android--MediaPlayer高级
  17. Lab 11-2
  18. Linux 查看CPU信息、机器型号等硬件信息[转]
  19. 三年java面试题
  20. disconf-web 分布式配置管理平台

热门文章

  1. C#中ESRI.ArcGIS.esriSystem的引用问题
  2. hadoop cdh 的那些坑 第二弹
  3. IntelliJ IDEA 2017.3尚硅谷-----插件的使用
  4. python面试的100题(9)
  5. input输入框在ios手机上获取焦点后有一个灰色阴影
  6. python 中if和elif的区别
  7. winform学习(1)初识winform
  8. Wx-小程序中使用伪类选择器实现border-1px
  9. 面试题17.打印从1到最大的n位数
  10. c++基础语法规则