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