Prevent caching

1,077 views
Skip to first unread message

Luca Lusso

unread,
Jan 21, 2014, 1:05:04 PM1/21/14
to guz...@googlegroups.com
Hi,
I've read that Guzzle do request caching only if cache plugin is enabled, but in my case this seems not true.

I'm using guzzle/guzzle 3.8.0 in a Symfony 2.4 application with this simple code in a controller: 

    $client = new Client($entity->getSiteUrl());
    $request = $client->get("/{$entity->getSiteKey()}");
    $data = $request->send()->getBody(TRUE);

A second request never hit the server. I need to pass a different query string each time to get newer results:

$request = $client->get("/{$entity->getSiteKey()}", array(), array('query' => array('abc' => '123')));

So it seems that Guzzle is doing per URL caching. What I'm missing?

Thanks

Luca

Dowling, Michael

unread,
Jan 21, 2014, 1:08:05 PM1/21/14
to guz...@googlegroups.com
Guzzle only caches responses if the cache plugin is enabled. There is absolutely no chance that Guzzle is caching responses unless you have a plugin enabled that does the caching. I suggest checking to see if your Symfony application is caching responses and providing a cached response to Guzzle's HTTP request.

Also note that the following code will only send one request:

    $client = new Client($entity->getSiteUrl());
    $request = $client->get("/{$entity->getSiteKey()}");
    $data = $request->send()->getBody(TRUE);

--Michael

--
You received this message because you are subscribed to the Google Groups "Guzzle - PHP HTTP client and REST client framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guzzle+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Luca Lusso (Wellnet)

unread,
Jan 21, 2014, 3:39:52 PM1/21/14
to guz...@googlegroups.com
Hi Michael,
if I fetch the URL directly with a browser I get a different response each time (it's a json with a timestamp). If I fetch the same URL with Guzzle I get the same json with the same timestamp (I get different response only with different query string parameters). Both client and server are on the same machine (a Mac), I dont'know how to debug this problem.

Thanks

Luca


--
You received this message because you are subscribed to a topic in the Google Groups "Guzzle - PHP HTTP client and REST client framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/guzzle/IiE9wDpoJ8E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to guzzle+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--

Luca Lusso - Senior Application Developer & Drupal specialist

WELLNET S.r.l. - "Benessere in rete" 
Piazzale Cadorna, 13 - 20123 - Milano
Tel. +39 02.87.39.86.38 - 
int. 108
Fax +39 02.36.63.94.30
Skype llusso-wellnet

www.wellnet.it
www.facebook.com/wellnet
www.twitter.com/wellnet

 

Le informazioni contenute in questo messaggio possono essere di natura riservata e confidenziale e sono indirizzate unicamente al destinatario. Qualora non siate il destinatario corretto, Vi è fatto divieto di utilizzare, copiare, diffondere o intraprendere qualsiasi azione basata su questo messaggio o sulle informazioni in esso contenute cosÌ come previsto dal D.Lgs.196/2003. Se avete ricevuto questo messaggio per errore, Vi preghiamo di comunicare immediatamente al mittente l'accaduto e di cancellare il messaggio. In ogni caso, Wellnet S.r.l. si dissocia da qualsiasi affermazione o opinione contenute nei messaggi inviati che non siano strettamente inerenti all'attività della stessa.

The contents of this e-mail are confidential and may contain attorney privileged information intended for the addressee only. In accordance with Italian privacy laws, if you are not the addressee indicated in this message, you may not copy, forward, disclose, deliver or otherwise use it, not even in part or in any form whatsoever. You should then kindly notify the sender by replying to this message and destroy it thereafter. Opinions, conclusions and other information in this message that do not relate to the official business of Wellnet S.r.l. shall be understood as neither given nor endorsed by them. 


Rispetta l'ambiente: se non è necessario, non stampare questo messaggio.
Please respect the environment, don't print this e-mail if it isn't necessary.

Matt Zuba

unread,
Jan 22, 2014, 9:43:01 AM1/22/14
to guz...@googlegroups.com, llu...@wellnet.it
Turn on Debugging and 'tail -f' your apache error log (/var/log/apache2/error.log, if running PHP as an apache module, for example) while you refresh the page to see the verbose CURL output.

$client->get("/{$entity->getSiteKey()}", array(), array('debug' => true));
Reply all
Reply to author
Forward
0 new messages