PHP Classes
elePHPant
Icontem

Cache Availability

Recommend this page to a friend!

      PHP Curl Class  >  All threads  >  Cache Availability  >  (Un) Subscribe thread alerts  
Subject:Cache Availability
Summary:Ask About Cache Availability
Messages:7
Author:nourmajed
Date:2020-03-10 06:53:34
 

 


  1. Cache Availability   Reply   Report abuse  
nourmajed - 2020-03-10 06:53:34
Hello

I want to ask if there Caching in this class when i send a request , and how it work if there is

Thank you

  2. Re: Cache Availability   Reply   Report abuse  
Josiah Ovye Yahaya - 2020-03-10 08:03:50 - In reply to message 1 from nourmajed
Hi,

The class supports request caching. How it works is; when you enable cache on the options passed to the class constructor, it will cache the first request for about 1200 seconds which is around 20 minutes then returns contents from the cache for subsequent requests for that URL.

Here is an example of enabling caching:

$curler = new Curler(['cache' => true]);

Then send your request e.g:
$response = $curler->get('https://example.com');

  3. Re: Cache Availability   Reply   Report abuse  
nourmajed - 2020-03-10 08:52:04 - In reply to message 2 from Josiah Ovye Yahaya
Is there any way to customize caching options like :

I want to cache some requests , but not all requests
If I can add parameter ['cache' => true] to a single request

  4. Re: Cache Availability   Reply   Report abuse  
Josiah Ovye Yahaya - 2020-03-10 09:41:16 - In reply to message 3 from nourmajed
If I understand you correctly, my answer is:

Caching is done per a request endpoint. Meaning, you can have some endpoints cached and some not cached. However, if this isn't what you're asking, kindly give more clarity so I can provide the right answer.

Thanks.

  5. Re: Cache Availability   Reply   Report abuse  
nourmajed - 2020-03-10 10:47:04 - In reply to message 4 from Josiah Ovye Yahaya
I'm trying to activate cache by adding this :

$curler = new Curler(['cache' => true]);

but it doesn't work the response isn't cached and it take much time in second request as the first time so I don't know if I misunderstand how to use it or it doesn't work at all.

How to check if the response came from cache or from actual server?

  6. Re: Cache Availability   Reply   Report abuse  
robert down - 2020-03-30 01:53:38 - In reply to message 2 from Josiah Ovye Yahaya
Thanks for the reply <a href="https://www.google.com/">.</a> was looking for this actually


  7. Re: Cache Availability   Reply   Report abuse  
robert down - 2020-03-30 01:54:03 - In reply to message 6 from robert down