Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onthegosystems/remote-files-cache
https://github.com/onthegosystems/remote-files-cache
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/onthegosystems/remote-files-cache
- Owner: OnTheGoSystems
- Created: 2019-02-06T11:01:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-27T14:53:27.000Z (almost 6 years ago)
- Last Synced: 2024-04-06T14:44:35.393Z (9 months ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 0
- Watchers: 16
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Remote Files Cache
A WP library for caching remote files. It caches the hash of the remote file in WP options table, avoiding multiple remote requests on the same file if the local file is up to date, saving bandwidth. It is done through a tiny HEAD request.
## Installation
```
composer require otgs/remote-files-cache
```## Usage
Checking if the cached file is up to date:
```php
$remote_file_cache = new OTGS_Remote_File_Cache( 'http://my-awesome.url' );if ( $remote_file_cache->is_up_to_date() ) {
//do not do the remote request
}
```Updating cache:
```php
$remote_file_cache = new OTGS_Remote_File_Cache( 'http://my-awesome.url' );//Do your stuff: request the file, etc.
$remote_file_cache->update();
```