PublicShow sourceurl_cache.pl -- Cache the content of external URLs in local files

This library provides a cache for data stored in extenal URLs. The content of each URL is kept in a file and described by a meta-file that remembers the mime-type, the original URL, when it was fetched and -if provided by the server- the last-modified stamp.

To be done
- The current implementation does not validate the cache content, nor does it honour the HTTP cache directives.
Source url_cache(+URI:atom, -Path:atom, -MimeType:atom) is det
Return the content of URI in a file at Path. MimeType is the Mime-type returned by the server.
Errors
- existence_error(url, URL) Server did not respond with 200 OK
- existence_error(source_sink, url_cache(.)) Cache directory does not exist
bug
- Does not check modification time and cache validity
Source url_cache_delete(+URL) is det
Delete an URL from the cache. Succeeds, even if the cache files do not exist.
Errors
- Throws exceptions from delete_file/1 other than existence errors.
Source url_cache_reset_server_status is det
Source url_cache_reset_server_status(+Server) is det
Reset the status of the given server or all servers.
Source url_cache_file(+URL, +Dir, +Ext, -Path) is det
Determine location of cache-file for the given URL in Dir. If Ext is provided, the returned Path is ensured to have the specified extension.
Source url_cached(?URL, ?Property) is nondet
Source url_cached(+Dir, ?URL, ?Property) is nondet
True if URL is in the cache represented by the directory Dir and has Property. Defined properties are:
file(-File)
File is the cache-file for the given URL
mime_type(-Mime)
Mime is the mime-type of the URL as reported by the server
fetched(-Stamp:integer)
Timestamp that specifies when the URL was fetched
last_modified(-Modified:atom)
If present, this is the modification time as provided by the server.
Source url_cache_reset_server_status is det
Source url_cache_reset_server_status(+Server) is det
Reset the status of the given server or all servers.
Source url_cached(?URL, ?Property) is nondet
Source url_cached(+Dir, ?URL, ?Property) is nondet
True if URL is in the cache represented by the directory Dir and has Property. Defined properties are:
file(-File)
File is the cache-file for the given URL
mime_type(-Mime)
Mime is the mime-type of the URL as reported by the server
fetched(-Stamp:integer)
Timestamp that specifies when the URL was fetched
last_modified(-Modified:atom)
If present, this is the modification time as provided by the server.