Any memory cache library for a static fileserver?

xuanbao · · 300 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I have a static fileserver written in Go which is serving html, css, js files for a single page application, which is only querying data from an API also written in Go. So far I happy with the performance and I&#39;m planning to not use Nginx at all, instead using HAProxy or other tool for load balancing.</p> <p>What I miss about Nginx is the ability to memory caching the assets, dropping the cache without restart, after how many requests to hit the cache, or set expiration time. Is there any good library (or function) which has similar functionality?</p> <hr/>**评论:**<br/><br/>jrwren: <pre><p>If you are talking about caching html, css, js files served from a linux file system you should strongly ponder doing nothing and allowing the kernel bufcache to do this for you.</p> <p>If you are talking about caching those API calculations, web responses, database response, there are many options from a simple map to redis and everything in between. I&#39;m leaning towards groupcache. <a href="" rel="nofollow"></a> I&#39;ll let you know how it goes.</p></pre>DJviolin: <pre><p>I only want to cache static files. Yes, the final project will be running on Linux. What do you mean by &#34;allowing the kernel bufcache to do this for you&#34;? Please explain it.</p></pre>014a: <pre><p>He means, if you&#39;re saying &#34;I want to cache these files on disk into memory so I can respond faster&#34; then the kernel pretty much does that for you. Don&#39;t worry about it.</p> <p>Nginx can sit on top of your entire app and give you a little more functionality here, more guarantees on how the caching will happen, more control. </p> <p>But in either case; you&#39;re micro-optimizing something that isn&#39;t that slow. The real level where &#34;caches&#34; operate at in modern web apps is outside of your app. For example: If all you&#39;re doing is serving static assets, that stuff should live on S3 and then be CDN&#39;d. </p> <p>If you&#39;d respond to that by saying &#34;my app isn&#39;t big enough to need that&#34;, then you might be right, but you also don&#39;t need any other caching solution. </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

300 次点击  
加入收藏 微博
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传