|
Output Object |
|
See Also: |
The Output.WriteIffChanged property sets/returns whether the output file is overwritten only when its contents change.
VBScript:
JScript:
| boolVal | True: Only overwrite the output file if the generated content differs from the existing file. False (Default): Always overwrite the output file. |
The Output.WriteIffChanged property is useful when using APGen in conjunction with replication, web file caching, and/or content delivery products. These products monitor static files (like .htm and .gif) for changes, and then copy the files when the files are detected to have changed. Setting Output.WriteIffChanged to True can minimize the workload and bandwidth used by replication, caching, and content delivery products.
For example, consider a scenario where a large number (20,000) of static pages are generated every few hours using APGen. The page content is extracted from a database and written to static HTML files. This generated content is replicated to 10 servers in a web farm. The content is also replicated to a cache in Europe, so European users get quicker responses and inter-continental bandwidth consumption is minimized. If Output.WriteIffChanged is False, all pages are replicated to the web farm and to the cache in Europe every few hours, which can be wasteful if only a small percentage of the pages change on average. By setting Output.WriteIffChanged to True, only the pages that change are overwritten and replicated.
When Output.WriteIffChanged is set to True, a buffer is created that accumulates all written content. When Output.Close() is called (explicitly or implicitly), the contents of this buffer are compared to any existing file at Output.Path. If the output file exists, and its contents are identical to the contents of the WriteIffChanged buffer, the file is left alone. Otherwise, the output file is overwritten with its new contents.
The WriteIffChanged buffer is not the same as the output buffer that is created by Output.Buffer. It is a new and separate buffer. The WriteIffChanged buffer receives the flushed output of the output buffer. The output object and buffers are chained as follows:
Output object --> [Output buffer] --> [WriteIffChanged buffer] --> output file