5

Context

I realized that in Twitter, the profile page is displayed in different ways depending on how it is called:

  1. By clicking the profile link in the menu, the DOM and the latest tweets are loaded, and the page is displayed in ~4 seconds. Each time.
  2. Using the keyboard shortcut GP (or the link on the left), the page is displayed instantly.

Details

  • I noticed that the profile must have been recently displayed for GP instantly displays the page.
  • By closing and opening the browser, the profile must be displayed again for GP instantly displays the page.

Investigation

So at first I thought Twitter could use a serverside session variable to store data. Then I discovered a use of localStorage in the Twitter source code. I confess, DOM storage is unfamiliar to me and the Twitter JavaScript code is unreadable. So I don't sure they use localStorage to store the profile.

Question

Any hypothesis, infos or links about Twitter DOM storage / session storage?

Community
  • 1
  • 1
GG.
  • 17,726
  • 11
  • 69
  • 117

1 Answers1

5

This is an interesting question, so I went to twitter, and did some investigation myself.

Clicking on my profile name, the link is done with AJAX. I see my timeline getting downloaded. But, the page is already loaded in advance, so my information is also already downloaded.

By clicking on the link on the left, or with GP you just display the page already loaded (hidden, or in JavaScript object, so in memory). It will just display your profile already downloaded, and by AJAX download the feed (JSON).

The URL will change from https://twitter.com/#!/ to https://twitter.com/#!/wraldpyk (in my case).

When you click your profile in the menu (top right) you go to https://twitter.com/wraldpyk. This will re-open the page, and will download everything. Note you will get redirected to https://twitter.com/#!/wraldpyk, and meanwhile your timeline also gets downloaded (open FireBug and see the images and feeds getting downloaded)

As far as I can tell, no local storage (except in JavaScript, like everyone does) is done. All data is constantly downloaded on new page load.

Same thing happens when you type gh when on your profile. (And also with all other shortcuts)

Rene Pot
  • 23,406
  • 6
  • 64
  • 89
  • Ok I didn't understand how a JavaScript object could move from one page to another. I searched without finding and finally I asked me this question: [What's the #! in Twitter URLs for?](http://stackoverflow.com/questions/3009380). So `https://twitter.com/#!/` and `https://twitter.com/#!/wraldpyk` are a single and same page? – GG. Feb 22 '12 at 01:03
  • Yes they are indeed. usually it's being used for Anchors (http://www.hypergurl.com/anchors.html). It doesn't make the page refresh. – Rene Pot Feb 22 '12 at 08:16