[html5] Newbie question about SharedWorkers

David John Burrowes davidjohnburrowes at gmail.com
Thu May 27 09:53:59 PDT 2010

Hello all,

I'm making my way through the spec about Workers, and have a question about SharedWorkers.

The spec makes various references to shared workers being used by multiple pages in parallel.  My question is can a shared worker be used by two sequentially accessed pages?  My reading of the spec says "no", but my intuition about what behavior I would "expect" says I should be able to.  Is my reading of the spec right?

Here's an example:
	We have two pages: P1 and P2 (from the same origin etc)
	P1 has a link to P2 on it (<a href="P2">) 

	Both P1 and P2 reference a shared worker SW

	When the user gets page P1, then SW is created.
	User then clicks on the link to P2

My interpretation of the spec says that when this link is clicked, P1 will be made no longer active, so it will be removed from SW's list of Documents.  This will leave SW's list empty, which will make it no longer a permissable worker. It's closing flag will be set to true, and presumably there's a chance it will be destroyed before P2 can be loaded and access SW.  So, P2 will need to re-create SW.

It seems desirable to me that if a page transition is being made between pages with compatible origins, that a shared worker would be preserved across them, allowing complex calculations being done by the worker to be shared by the pages (obviously, the worker could be storing its work in a database, and then reloading that when it is created.  But, that seems like overkill)



More information about the Help mailing list