When a user lands on my page, say, www.somepage.com, I want to display some randomised content. But I want that content to be bookmarkable, so the URL should be changed on the client to something like 'www.somepage.com/?showparts=2,7,12', where the numbers can be different.
I do not want to do a redirect every time the user goes to 'www.somepage.com' so that it refers the user to 'www.somepage.com/?showparts=2,7,12', since that will require 2 round trips of communication with the server, making the site appear slow to the user.
So is there a way to make the user's browser show the URL as 'www.somepage.com/?showparts=1,4,6,30' in the one request and response when they navigate to 'www.somepage.com'?
I have read this thread: Is there a way to change the browser's address bar without refreshing the page?
But that thread is about changing the page after user interaction, so after the page has already been loaded on the client.
My question is about whether there is a response code or something to change the browser's URL in the first response sent from the server to the client when the client first navigates to the site.
I have read about history.js (https://github.com/browserstate/history.js), but I was wondering if there's a more simple solution in a response code or something. If the only solution is to use history.js, how should I do it? I was thinking that I could add a javascript call to the html page sent from the server as follows:
History.pushState(null, null, "?showparts=1,4,6,30");
Any pointers would be appreciated.
Thanks,
Keith