Question

This issue really puzzles me. I'll start by explaining what I'm trying to do:

On a website I'm developing, I would like to display albums with photos retrieved from a specific account on Picasa. For this, I'm using the XML feed (http://picasaweb.google.com/data/feed/api/user/userID). I load this feed using a SimpleXMLElement object.

Now the weird thing is, when I add/delete a photo to/from an album, the changes take some time (usually a few minutes) to take effect. The PHP object still receives the old data. Now this wouldn't be that strange, considering Google might want to limit the amount of requests, however, when loading the feed in Firefox, the changes are displayed immediately.

What is causing this delay, and can I do anything about it? Is there any difference between FF and PHP when retrieving the feed? I noticed this question has been asked a while back, but without any answers, and I thought it's a bit too old to necro it.

I have tried using both file_get_contents and curl, but neither seems to work. Apparently the problem is not with PHP, since in the other question C# was used.

edit - here is the request header from Firefox:

Expires: Fri, 16 Nov 2012 19:22:45 GMT
Date: Fri, 16 Nov 2012 19:22:45 GMT
Cache-Control: private, max-age=0, must-revalidate
Content-Type: application/atom+xml; charset=UTF-8; type=feed
Vary: Accept, X-GData-Authorization, GData-Version, Cookie
GData-Version: 2.0
Etag: W/"DEEBQnk9fyp7ImA9WhNQEEU."
Last-Modified: Fri, 16 Nov 2012 17:24:13 GMT
Content-Encoding: gzip
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE

200 OK

and the response header from curl:

HTTP/1.1 200 OK
Expires: Fri, 16 Nov 2012 19:30:26 GMT
Date: Fri, 16 Nov 2012 19:30:26 GMT
Cache-Control: private, max-age=0, must-revalidate, no-transform
Set-Cookie: _rtok=lL_1sPFA07ra; Path=/; HttpOnly
Set-Cookie: S=photos_html=jHfi_UGm4xVujZVehiIOpw; Domain=.google.com; Path=/; HttpOnly
Content-Type: application/atom+xml; charset=UTF-8; type=feed
Vary: Accept, X-GData-Authorization, GData-Version, Cookie
GData-Version: 2.0
ETag: W/"DEEBQnk9fyp7ImA9WhNQEEU."
Last-Modified: Fri, 16 Nov 2012 17:24:13 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked

edit 2: I think I figured it out! Apparently, the feed only updates every few minutes when viewed anonymously. However, Firefox had my Picasa login session stored, so it counted as an authorized request. Chrome did not have this session, and therefore didn't update instantly either. Once I also allowed Picasa to store a cookie in Chrome, it did update instantly, while Opera was still delayed. Gonna put an answer to the other question just in case the poster is still interested.

Thanks for the hint in the comments, this has led me to discovering the cause. If you could put it down as an answer, I'll accept that one.

Was it helpful?

Solution

Check the request/response headers for the PHP request and the Firefox request. That should provide insight into why it works in one instance and not the other.

In your case, as you identified on your own (good job btw), Firefox had your Picasa authorization credentials which allowed to to retrieve non-cached version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top