URL Caching Example

Initialize component

<?php
	require_once("url_caching.php");
	$url_caching = new URLcaching();
?>

Example 1 - Cache expires after two hours

<?php
	$responseBody = $url_caching->getRequest("http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml", time() + 7200);
?>

Warning: file_put_contents(/var/www/catalog.wccnet.edu/_resources/php/url-caching/cache/cache.log): failed to open stream: Permission denied in /var/www/catalog.wccnet.edu/_resources/php/url-caching/url_caching.php on line 126

Notice: Undefined variable: httpcode in /var/www/catalog.wccnet.edu/_resources/php/url-caching/url_caching.php on line 65

Fatal error: Uncaught Exception: http://catalog.wccnet.edu//_resources/php/url-caching/caching_helper.php?url=http%3A%2F%2Frss.nytimes.com%2Fservices%2Fxml%2Frss%2Fnyt%2FHomePage.xml&cache_path=%2Fvar%2Fwww%2Fcatalog.wccnet.edu%2F_resources%2Fphp%2Furl-caching%2Fcache%2F0ff78711aa5338000cd51de1b95e795e73a6644c474ed30c72a58b43011a0009.cache&expiration=1632471219 responded with status code: in /var/www/catalog.wccnet.edu/_resources/php/url-caching/url_caching.php:65 Stack trace: #0 /var/www/catalog.wccnet.edu/_resources/php/url-caching/example.php(36): URLcaching->getRequest('http://catalog....', 1632471219) #1 {main} thrown in /var/www/catalog.wccnet.edu/_resources/php/url-caching/url_caching.php on line 65