views:

118

answers:

2

I'm experiencing a behaviour of Google Chrome (Google Chrome 7.0.517.41 beta) that I can't understand. In some cases, Google Chrome downloads the source code of the PHP script that is requested from my server instead of it being executed. I don't have this problem with cURL or Firefox; when I request the same URL with them the script is executed properly.

This seems to me rather odd because I this should be a server issue and it should work the same in every browser. I think I must have overlooked something or Google Chrome is sending some unusual HTTP headers... I don't know. I've checked AddHandler and AddType directives in Apache configuration files with no success. Do you have any idea what might be causing this?

A: 

Web server will not let any browser download the raw .php file. No matter how Chrome or any other browser requests the page, the server will first run the PHP interpreter and return its output as a page.

It seems like your Chrome browser just downloads that result as a file instead of actually displaying it as a web page.

Try clearing auto-opening settings first:

You can clear auto-opening settings through the Options dialog (Preferences on a Mac). Here's how:

Click the wrench icon on the browser toolbar. Mac users: If you don't see the wrench icon, go to the menu bar at the top of your screen and click Chrome. Select Options (Preferences on a Mac). Click the Under the Hood tab. In the "Downloads" section, click Clear auto-opening settings. This clears your settings for all file types. Click Close when you're done, if you're using Windows or Linux.

Another possible cause of the problem is a Download Manager. You have to disable Chrome support in any download manager you might be using. See this thread for details.

Hope it helps. Good luck!

Vlad Lazarenko
that is assuming the server is set up correctly.
jalf
Yes, I understand all of this, but the thing is that Google Chrome downloads the *source code* of the PHP script, not the output of its execution. (I've editted it in the question to make it more clear.)
jindrichm
@jalf: I think the problem must be in the combination of my server not being set-up propertly and Google Chrome sending some *specific* HTTP requests.
jindrichm
+1  A: 

The solution for this issue was to clear the Google Chrome's cache which seems to hold some data cached for too long. It was probably wrong on the server as it was sending raw PHP code previously but due to caching this issue persisted for Google Chrome even after it was fixed.

Thanks to Jon Cram for the suggestion.

jindrichm