Search code examples
javascriptphpapachehttpd.conf

Why are my PHP and Javascript changes not manifesting?


I have a local server running on my linux computer that is using an index.html, javascript.js and a php_file.php. When I make changes to the index.html and I reload the site, the changes are visible. However when I make changes to the php or javascript file the changes are never made. When I look at the developer tools in chrome for the website, the website is still using the old undedited and unfixed javascript and php file! How do I solve this without having to reboot my computer every time I have made progress to my js and php file?

Relevant info: I am on Arch Linux and I have tried 'systemctl restart httpd', 'pkill httpd', 'pkill mysqld', etc. and then started the processes again. That does not fix the issue.


Solution

  • PHP files are server-side files, that is, they run on the server and Javascript are client-side files, which run on client-side, that is, in the browser of the users.

    Even though the server-side and the client-side happens to be the same physical machine in your case while you are developing your site, you need to separate the two in your thoughts as if they were running on two different machines.

    The fact that your changes are not applying suggests that there is some caching involved. That means that some files are stored somewhere to make sure they can quickly be accessed. The question is: what is cached in your case? The PHP (server-side) or the Javascript (client-side)?

    If there is a server-side cache being involved, then you might want to switch off server caching on your dev environment, you don't really have many thousands of users to serve at the same time by your dev environment.

    If for some reason you cannot switch off server-side caching at your dev env for some reason, then you can empty the cache whenever you switch to testing.

    Since your client-side files are running in a web-browser, they follow the browser's caching protocol. You can remove cached files in your browser. You can also open an incognito window in order to test.

    Just make sure you do not clear the full browsing history, so you will not be logged out from all the sites where you have an active session.