新手,使用Ruby构建一个小型应用程序
我现在正在学习 Ruby,我遇到了困难,也许你们可以帮助我一点。
我想构建一个基于 Sinatra 的小型应用程序,它可以增加一个值并根据不同的请求打印它。你转到根页面,你会得到 1,如果你刷新页面,你会得到 2,依此类推。
我不知道如何让增量仅在刷新时发生
谢谢
I'm learning Ruby right now and I got stuck, maybe you guys can help me a bit.
I want to build a small app based on Sinatra that increments a value and prints it on different requests. You go to the root page and you get 1, if you refresh the page you get 2 and so on.
I have no ideea how to get the increment to happen only on refresh
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的方法是检测页面刷新:
/增量
)HTTP_CACHE_CONTROL
标头:max-age=0
(对于使用F5
或reload
按钮时的 FF)无缓存
(适用于使用CTRL-F5
时的 FF 和 IE)我希望这可以帮助您开始使用您的应用程序:)
My approach is to detect a page refresh is:
/increment
)HTTP_CACHE_CONTROL
header for:max-age=0
(for FF when usingF5
orreload
button)no-cache
(for FF and IE when usingCTRL-F5
)I hope this helps you to start with your app :)