Automatically Updating a Web Page When a Server-Side File Changes

Figure 16-15 and Figure 16-16 demonstrate how to use HEAD calls, server-side file reading, and the cache-tricking technique to read a file from a webserver, display its contents, and update the contents whenever the file on the server changes. This type of application is useful whenever more than one person can update a file on a webserver—for example, if two people have access to the same To Do list.

Client-side checking for updated server-side file

Figure 16-15. Client-side checking for updated server-side file

Figure 16-15 lists the client-side portion of the application. Clicking the Read the File button in the form at the bottom ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.