TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Redis server side if-modified-since caching pattern using lua

55 点作者 r4um将近 4 年前

3 条评论

irthomasthomas将近 4 年前
You can do something similar using the Expire TTL by setting a date way in the future.<p><pre><code> redis-cli SETEX mykey 310536000000 &quot;helllooo&quot; myttl = $(redis-cli TTL mykey) mdate = 310536000000 - $myttl</code></pre>
评论 #27593182 未加载
habibur将近 4 年前
Also note that HTTP had it since early days.<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;HTTP&#x2F;Headers&#x2F;If-Modified-Since" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;HTTP&#x2F;Headers&#x2F;If...</a><p>And Apache and other web servers support it out of the box.<p>If your use case allows it consider ditching Redis and rather static cache your generated HTML&#x2F;json files on the file system while serving. And let Apache serve from there as long as those cached files exist. You get all these features for free.
评论 #27590300 未加载
bnajdecki将近 4 年前
Really well-explained article.