Simple But Clever Java Server Trick

i-Technology Viewpoint: Laziness Sometimes Pays (SYS-CON) As the author of this piece says, it is very very common for server applications to write out the same file over and over again. If a given page already exists in exactly the form you are about to write then why write it again, end up changing the date on the file, and then cause the user to download it again? So he substitutes a specialized version of the OutputStream that compares the data you are writing to the file that already exists if there is one there. As soon as it notices a difference it begins to change the file, but should it never change, then it leaves the file untouched so the browsers on remote machines may skip downloading it if they have a copy cached.
Simple, but clever.

Advertisements