PHPackages                             maheshwaghmare/wp-dev-remote-request - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. maheshwaghmare/wp-dev-remote-request

ActiveLibrary[Caching](/categories/caching)

maheshwaghmare/wp-dev-remote-request
====================================

Cache the HTTP reqeust and store into the transient for given expiration time to avoid the remote requests.

1.0.0(5y ago)221MITPHPPHP &gt;=5.3.0CI failing

Since Apr 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/maheshwaghmare/wp-dev-remote-request)[ Packagist](https://packagist.org/packages/maheshwaghmare/wp-dev-remote-request)[ Docs](https://github.com/maheshwaghmare/wp-dev-remote-request)[ RSS](/packages/maheshwaghmare-wp-dev-remote-request/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

WP Dev Remote Request
=====================

[](#wp-dev-remote-request)

The "WP Dev Remote Request" package provide the function `wp_dev_remote_request_get()` which allow us to send the HTTP requests and store the response into the transient.

So, If we resend the request then it serve the data from the transient.

If transient get expired, then it trigger the live request and store the data into the transient and return the response.

Internally use the wp\_remote\_\*() functions to send the remote requests.

Syntax
------

[](#syntax)

```
wp_dev_remote_request_get( string / array() );
```

Below are some quick examples:

```
// Example 1:
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/' );

// Example 2:
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/?_fields=title' );

// Example 3:
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/?per_page=5&_fields=title' );

// Example 4:
$response = wp_dev_remote_request_get( array(
    'url' => 'https://maheshwaghmare.com/wp-json/wp/v2/posts/',
) );

// Example 5:
$response = wp_dev_remote_request_get( array(
    'url' => 'https://maheshwaghmare.com/wp-json/wp/v2/posts/?_fields=title',
) );

// Example 6:
$response = wp_dev_remote_request_get( array(
    'url' => 'https://maheshwaghmare.com/wp-json/wp/v2/posts/',
    'query_args' => array(
        'per_page' => 5,
        '_fields' => 'title',
    )
) );
```

Parameters
----------

[](#parameters)

Below is the list of default parameters:

```
'url' => '',
'query_args' => array(),
'remote_args' => array(
    'timeout' => 60,
),
'expiration' => MONTH_IN_SECONDS,
'force' => false,
```

How it works?
-------------

[](#how-it-works)

The package provide the function `wp_dev_remote_request_get()` to send the HTTP request.

```
// "First" request for URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/' );
var_dump( $response );
// array(
// 		'success' => true,
// 		'message' => 'Response from live site.',
// 		'data' => array(
//			...
// 		),
// )

// "SECOND" request for URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/' );
var_dump( $response );
// array(
// 		'success' => true,
// 		'message' => 'Response from transient.',
// 		'data' => array(
//			...
// 		),
// )

// "Third" request for URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/' );
var_dump( $response );
// array(
// 		'success' => true,
// 		'message' => 'Response from transient.',
// 		'data' => array(
//			...
// 		),
// )
```

Here, We can see the live HTTP request send only for the first time and for next request it return the cached response from the transient.

In above example we have pass the `https://maheshwaghmare.com/wp-json/wp/v2/posts` as parameter into the function `wp_dev_remote_request_get()`;

Let's see another example with additional parameters.

How to request considered as unique request?
--------------------------------------------

[](#how-to-request-considered-as-unique-request)

The remote request data is stored into the transient.

So, While storing the data into the transient it create a unique transient key with the help of the HTTP request URL.

E.g.

```
wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/' ); // Unique request.
wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/?per_page=10' ); // Unique request.
wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/?per_page=5' ); // Unique request.
wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/?per_page=5&_field=title' ); // Unique request.
wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/?_field=title&per_page=5' ); // Still unique request.

```

Install
-------

[](#install)

Install with Composer
---------------------

[](#install-with-composer)

Install the package with composer using below command:

```
composer require maheshwaghmare/wp-dev-remote-request
```

After installing the package simply use function `wp_dev_remote_request_get()`.

E.g.

```
// Load files.
require_once 'vendor/autoload.php';

// "First" request for URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/' );
var_dump( $response );
// array(
// 		'success' => true,
// 		'message' => 'Response from live site.',
// 		'data' => array(
//			...
// 		),
// )

// "SECOND" request for URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/' );
var_dump( $response );
// array(
// 		'success' => true,
// 		'message' => 'Response from transient.',
// 		'data' => array(
//			...
// 		),
// )

// "Third" request for URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
$response = wp_dev_remote_request_get( 'https://maheshwaghmare.com/wp-json/wp/v2/posts/' );
var_dump( $response );
// array(
// 		'success' => true,
// 		'message' => 'Response from transient.',
// 		'data' => array(
//			...
// 		),
// )
```

Visit

Debugging
---------

[](#debugging)

If you enable the debug log and then try to send the request the you can see the logs into the `debug.log` file.

Below is the log of above code:

```
[21-Jan-2021 13:42:48 UTC] REQUEST URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
[21-Jan-2021 13:42:48 UTC] ARGS: {"url":"https:\/\/maheshwaghmare.com\/wp-json\/wp\/v2\/posts\/","query_args":[],...
[21-Jan-2021 13:42:48 UTC] TRANSIENT_KEY: wp-dev-remote-request-bd2bab32e19a4d142e99051fcda7f4e7
[21-Jan-2021 13:42:52 UTC] RESULT: (Live) [{"id":37012,"date":"2021-01-18T23:33:10","date_gmt":...
[21-Jan-2021 13:42:53 UTC] MESSAGE: Response from live site.
[21-Jan-2021 13:42:53 UTC] DURATION: 5 seconds
[21-Jan-2021 13:42:53 UTC] REQUEST URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
[21-Jan-2021 13:42:53 UTC] ARGS: {"url":"https:\/\/maheshwaghmare.com\/wp-json\/wp\/v2\/posts\/","query_args":[],...
[21-Jan-2021 13:42:53 UTC] TRANSIENT_KEY: wp-dev-remote-request-bd2bab32e19a4d142e99051fcda7f4e7
[21-Jan-2021 13:42:53 UTC] RESULT: (Cached) [{"id":37012,"date":"2021-01-18T23:33:10","date_gmt":...
[21-Jan-2021 13:42:53 UTC] MESSAGE: Response from transient.
[21-Jan-2021 13:42:53 UTC] DURATION: 1 second
[21-Jan-2021 13:42:53 UTC] REQUEST URL: https://maheshwaghmare.com/wp-json/wp/v2/posts/
[21-Jan-2021 13:42:53 UTC] ARGS: {"url":"https:\/\/maheshwaghmare.com\/wp-json\/wp\/v2\/posts\/","query_args":[],"remote_args":{"timeout":60},"expiration":2592000,"force":false,"start_time":1611236573,"end_time":1611236573,"duration":0}
[21-Jan-2021 13:42:53 UTC] TRANSIENT_KEY: wp-dev-remote-request-bd2bab32e19a4d142e99051fcda7f4e7
[21-Jan-2021 13:42:53 UTC] RESULT: (Cached) [{"id":37012,"date":"2021-01-18T23:33:10","date_gmt":...
[21-Jan-2021 13:42:53 UTC] MESSAGE: Response from transient.
[21-Jan-2021 13:42:53 UTC] DURATION: 1 second

```

Here, We can see the **first** request takes the **5 seconds** because it send the live request.

But, The **second** and **third** request takes the **1 second** because it get the response from the transient.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~270 days

Total

2

Last Release

1989d ago

Major Versions

0.0.1 → 1.0.02021-01-21

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4434582?v=4)[Mahesh Waghmare](/maintainers/maheshwaghmare)[@maheshwaghmare](https://github.com/maheshwaghmare)

---

Top Contributors

[![maheshwaghmare](https://avatars.githubusercontent.com/u/4434582?v=4)](https://github.com/maheshwaghmare "maheshwaghmare (8 commits)")

---

Tags

wordpresscacheREST API

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/maheshwaghmare-wp-dev-remote-request/health.svg)

```
[![Health](https://phpackages.com/badges/maheshwaghmare-wp-dev-remote-request/health.svg)](https://phpackages.com/packages/maheshwaghmare-wp-dev-remote-request)
```

###  Alternatives

[wp-media/wp-rocket

Performance optimization plugin for WordPress

7531.3M3](/packages/wp-media-wp-rocket)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23617.1k1](/packages/rtcamp-nginx-helper)[rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

14115.4k2](/packages/rarst-fragment-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
