This app is a very simplistic app designed to satisfy the requirements of the Augur.io interview test.
This uses only server-side logic (as long as you agree that utilizing the browser's cache doesn't constitute "logic").
I used Express and bower (just to get jquery for convenience). Thus, to setup and run the app, do the following...
npm install -g bower
npm install
bower install
node .
- Navigate to
http://localhost:3000/
Flow
All true logic is server-side, although it does rely on the browser's cache to achieve the desired results.
- The user navigates to the app for the first time
- The file
public/index.html
is served (predictably) - A script asset called
/tag.js
is requested, which is a dynamic route setup inindex.js
- This route checks for the presence of an
if-modified-since
header. Absence of this header indicates this is the first time this client has hit the site (since clearing local cache, of course). If the header IS present, we simply return an empty304
response to indicate that the browser should load the cached version. - If no
if-modified-since
header is present, a new unique id is generated, and this is sent to the client in a very minimal generated javascript file that simply sets a global variable calledtag
. - On, the client, this value is rendered in the DOM (not a very useful web page) via the static script asset at
public/render_tag.js
. - Another static asset at
public/report_tag.js
is loaded, which tells the server what the value of the tag is (whether or not this was newly generated or loaded from cache). - The server keeps a naive in-memory store of known browsers, including a simple little counter which gets logged to the console on each page request.
Caveat
This, of course, breaks down when the user clears their cache. It does still satisfy the requirements of the test as far as I can tell (retains browser tagging regardless of cookies).