Empty the cached NaCl and force the Chrome to reload it programmatically

630 views
Skip to first unread message

DevelopDaily

unread,
Sep 27, 2013, 5:56:25 PM9/27/13
to native-cli...@googlegroups.com
The Chrome reload button has these options:

Normal Reload                          Ctrl+R
Hard Reload                              Ctrl+Shft+R
Empty Cache and Hard Reload

The third option is extremely useful during the development of NaCl apps.

After a new revision of an NaCl app is deployed, I don't want to bother the end users to press the "Empty Cache and Hard Reload" to reload the new revision. I want to use the JavaScript to do the equivalent of the "Empty Cache and Hard Reload" to make sure the delivery of the latest app to the users.

I understand the Chrome is supposed to refresh the NaCl apps in the cache, but I do notice, quite often, my latest apps are not loaded into the Chrome. When that happens, the "Empty Cache and Hard Reload" solves the problem every time.



Nick Bray

unread,
Sep 27, 2013, 6:17:29 PM9/27/13
to native-cli...@googlegroups.com
My personal weapon of choice is: JavaScript Console => Gear Icon in Lower Right Corner => Disable cache (while DevTools is open).  Every time you want to check a release, open the JavaScript Console and then hit reload.  (I don't think this will bypass PNaCl's translation caching, but I believe it will force PNaCl to query and see if the underlying data has changed.)


--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Visit this group at http://groups.google.com/group/native-client-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

DevelopDaily

unread,
Sep 28, 2013, 12:37:27 AM9/28/13
to native-cli...@googlegroups.com
Perhaps my original message is not clear.

Nick Bray's suggestion and the "Empty Cache and Hard Reload" are effective for developers to manage the cache. But my intent is to help the average end users get the latest apps without any extra steps such as opening the JavaScript Console.

So, my question is how to clear the cache by the JavaScript in my web page as if it were done by the "Empty Cache and Hard Reload."

Darin Fisher

unread,
Sep 28, 2013, 12:50:30 AM9/28/13
to Native-Client-Discuss
One hackish way is to use XHR to fetch the NMF and PEXE(s), but specify a "pragma: no-cache" request header when you do so.

Note: If all you really want to do is force the result to be fresh, then you should use "cache-control: max-age=0" instead. That way you don't preclude the servers ability to respond with a 304 Not Modified.

If you were going to do this, there is a bit of waste as you would be streaming the data to JavaScript for no good reason. One way to mitigate that might be to set the XHR's responseType to "blob". Then at least the bytes would not need to be processed by JS, but I think this may still be fairly inefficient in Chrome.

The above is not recommended for production.

-Darin


--

Darin Fisher

unread,
Sep 28, 2013, 12:51:38 AM9/28/13
to Native-Client-Discuss
I should note that the PEXE translation cache might defeat my suggestion :-/

Nick Bray

unread,
Sep 28, 2013, 1:17:42 AM9/28/13
to native-cli...@googlegroups.com
Would changing/versioning the URL work?  This would have the virtue of working for all caches - not just the browser, but a CDN, etc.  The downside is the caches wouldn't know they should reap the previous version, but it's a tradeoff.


On Fri, Sep 27, 2013 at 9:37 PM, DevelopDaily <c...@datacivilization.com> wrote:

--

Jan Voung

unread,
Sep 28, 2013, 11:53:36 AM9/28/13
to native-cli...@googlegroups.com
That forces revalidation with the origin server right?  As long as the server sends a different Last-Modified time or a different ETag for the new pexe, then the PEXE translation cache will get a cache-miss and force re-translation of the new pexe.
Reply all
Reply to author
Forward
0 new messages