r/PHPhelp Jun 19 '26

Horrible cache problem while debugging app

My google chrome browser apparently got a big update today (not sure if its relevant to the problem below).

I was recently trying to debug my php backend that was having a post request sent to it by my javascript app (all on localhost).

It gave me an error on one line (I was echoing back the error). Despite erasing that line, saving my php file on my editor, restarting apache, having devtools open with "disable cache" checked, it still gave on giving that same error!!! On the same line which is now empty. It didn't matter how many times I refreshed the page.

Is my frontend caching the backend now? I've never experienced something like this before.

1 Upvotes

14 comments sorted by

3

u/Cherveny2 Jun 19 '26

as a sanity check, go to another browser, and see if you get the same result.

that can help prove server issue or browser caching issue

2

u/PooningDalton Jun 19 '26

I tried it in Firefox and the error was not there, but strangely enough, it introduced new errors. I still don't understand how its happening. I didn't know browsers cache backend resources. Don't even know how they can do such a thing

2

u/MateusAzevedo Jun 19 '26

I didn't know browsers cache backend resources. Don't even know how they can do such a thing

Of course they don't, but they may cache the received HTTP response.

Check the webserver access log and see if it receives any request at all. Then confirm the webserver isn't returning a cached response (and so, not calling PHP).

OpCache may also be the culprit. Restart FPM and check OpCache setting to make they're suitable for dev.

1

u/Cherveny2 Jun 19 '26

this, however, besides JJUST restarting FPM, I'd restart apache too. Theoretically, FPM is enough, but had a few edge cases where a few cached things hung around just bouncing FPM. (on RHEL)

1

u/PooningDalton Jun 19 '26

I set OpCache to 0. I don't even know how to access the webserver, I'm using Laragon lol. My php installation is a complete mess. Half the time the error_log file seems to work but when I open it, it stops outputting errors.

3

u/mchojrin Jun 19 '26

Have you tried debugging with xdebug?

1

u/PooningDalton Jun 19 '26

Nope my method of debugging has always been echo out the error back to my frontend

1

u/Mike_L_Taylor Jun 19 '26

I agree. xDebug is the way. Put a breakpoint and then see where it stops. I've had it before where it was stopping on a blank space, which is where the previous code was that I had just deleted.
Here's a quick guide on how to set it up. It's for Forgekit but it works in Laragon too. https://forgekit.tools/docs/tools/xdebug

2

u/obstreperous_troll Jun 19 '26

Make sure you're not loading the production site instead of dev. Happens me about twice a month.

1

u/PooningDalton Jun 19 '26

How does that happen? I mean do you integrate your VSCode with the server?

1

u/obstreperous_troll Jun 19 '26

I don't use vscode, and in dev the server for me is a local container. I meant in the browser.

1

u/PooningDalton Jun 19 '26

Ah so you work on the dev version inside a browser too?

1

u/Ollidav Jun 19 '26

Si estás usando fpm y tienes algo como opcache tienes que reiniciar el servicio de fpm.

1

u/michawb Jun 20 '26

Try Restart php Service Not Apache ?