<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'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'm leaning towards groupcache. <a href="https://github.com/golang/groupcache" rel="nofollow">https://github.com/golang/groupcache</a> I'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 "allowing the kernel bufcache to do this for you"? Please explain it.</p></pre>014a: <pre><p>He means, if you're saying "I want to cache these files on disk into memory so I can respond faster" then the kernel pretty much does that for you. Don'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're micro-optimizing something that isn't that slow. The real level where "caches" operate at in modern web apps is outside of your app. For example: If all you're doing is serving static assets, that stuff should live on S3 and then be CDN'd. </p>
<p>If you'd respond to that by saying "my app isn't big enough to need that", then you might be right, but you also don't need any other caching solution. </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传