新手,使用Ruby构建一个小型应用程序

发布于 2024-08-03 14:37:10 字数 163 浏览 2 评论 0原文

我现在正在学习 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睫毛溺水了 2024-08-10 14:37:10

我的方法是检测页面刷新:

  • 定义一个单独的“刷新”链接(/增量
  • 检查HTTP_CACHE_CONTROL标头:
    • max-age=0(对于使用 F5reload 按钮时的 FF)
    • 无缓存(适用于使用 CTRL-F5 时的 FF 和 IE)

我希望这可以帮助您开始使用您的应用程序:)

My approach is to detect a page refresh is:

  • defining a separate "refresh" link (/increment)
  • checking HTTP_CACHE_CONTROL header for:
    • max-age=0 (for FF when using F5 or reload button)
    • no-cache (for FF and IE when using CTRL-F5)

I hope this helps you to start with your app :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文