tags:

views:

111

answers:

1

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

+1  A: 

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 :)

splattael
Thanks for your help!
Stack