Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Philip Powis
Philip Powis
7,625 Points

php caching?

I notice that when i make changes to my php files following along on the basic php project, I have to continuously refresh/wait a few minutes before the updates are reflected in the browser.

I assume the browser is caching the PHP code for a bit? Is there a way to keep the browser from doing this in a development environment?

Secondarily, I'm assuming there are benefits to the browser caching your code in a production environment, but are you as a developer able to exert any level of control over this?

Best,

Phil

5 Answers

Lee Chavers
Lee Chavers
22,506 Points

Philip, you can hold down the shift button while clicking refresh and that should tell most browsers to pull a fresh copy instead of from cash. Another trick if you use Chrome as your browser, open up your inspector element (right click > inspect element or command+option+i on the mac), go to your settings (gear icon on the bottom right) one of the options should be Disable Cache (while DevTools is open), click that checkbox and that should help you.

I have tried all those tricks and even installed the Cache Killer plugin. It works great for most pages but the contact-process page is still getting cached. Any ideas?

Lee Chavers
Lee Chavers
22,506 Points

Is this on a local server or a remote server?

Local. MAMP standard install on my Mac.

Lee Chavers
Lee Chavers
22,506 Points

Can you tell me a little more about your setup? Handwritten php? Wordpress?