otgs/remote-files-cache

一个用于缓存远程文件的 WP 库

dev-master 2019-02-06 16:48 UTC

This package is auto-updated.

Last update: 2024-08-28 04:05:29 UTC


README

一个用于缓存远程文件的 WP 库。它会在 WP 选项表中缓存远程文件的哈希值,如果本地文件是最新的,则避免对同一文件进行多次远程请求,从而节省带宽。这是通过一个微小的 HEAD 请求实现的。

安装

composer require otgs/remote-files-cache

用法

检查缓存的文件是否是最新的

$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
}

更新缓存

$remote_file_cache = new OTGS_Remote_File_Cache( 'http://my-awesome.url' );

//Do your stuff: request the file, etc.

$remote_file_cache->update();