TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

55 pointsby r4umalmost 4 years ago

3 comments

irthomasthomasalmost 4 years ago
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 未加载
habiburalmost 4 years ago
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 未加载
bnajdeckialmost 4 years ago
Really well-explained article.