Jump to content

PHP pages updates slow to reflect in browser


Recommended Posts

Hello folks,

I'm running PHP Version 7.1.4, on Lighttpd 1.4.32 on my old NAS device (so can't really do PHP /Lighttpd updates).

I'm developing this project that uses sessions, but have a really annoying problem where every time I do a change in a PHP file, reloading the page in my browser won't show the change right away, as if it was cached somehow, showing still older version... I have to keep hitting reload in my browser for, let's say ~40 seconds or so, and at some point, it will show my changes. 

This drives me nuts when trying to troubleshoot a problem!

The thing is, it happens only with PHP files. Changes in regular HTML files are reflected right away.

I've tried the followings in order to pin-out the problem:

  1. cleared my browser's cache completely
     
  2. added the following cache-control directives inside my Lighty server config file: 
    setenv.add-response-header += ("Cache-Control" => "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0, post-check=0, pre-check=0")

     

  3.  set nocache session limiter in php.ini:
    session.cache_limiter = nocache
  4. manually changed the HTTP Headers right from the PHP file:
    header("Expires: Tue, 03 Jul 2001 06:00:00 GMT", true);
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT", true);
    header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0", true);
    header("Pragma: no-cache", true);
    header("Connection: close", true);

     


Problem always remains the same. And yes, I did confirm with a HTTP Headers Chrome plugin that the headers were indeed modified on every try that I did above... As of try#4, my headers in my PHP files look like:

Content-Language    en
P3P                 CP='CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR'
Cache-Control       no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0, post-check=0, pre-check=0
Cache-Control       no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
X-Powered-By        PHP/7.1.4
Expires             Tue, 03 Jul 2001 06:00:00 GMT
Last-Modified       Sat, 22 Feb 2020 20:18:01 GMT
Pragma              no-cache
Connection          close
Content-Encoding    gzip
Vary                Accept-Encoding
Content-type        text/html; charset=UTF-8
Transfer-Encoding   chunked
Date                Sat, 22 Feb 2020 20:18:01 GMT
Server              lighttpd/1.4.32


Running out of ideas here... Any help would be great!

Cheers,
Pat

Link to comment
Share on other sites

Open your browsers development console (F12) and disable the use of cache (Network tab -> [X] Disable Cache) and see if that resolves the problem.  If it does, you know it's a browser cache issue.  If it doesn't, you know the problem lies elsewhere.

Have you experienced the issue in multiple browsers, or have you only been using one?

Link to comment
Share on other sites

Here's my phpinfo() http://corbeauperdu.ddns.net/phpinfo.php

I tried disabling cache from my browser's dev tools , as you said kicken, but problem remains :(

 

Additional info, if it applies, I'm running php-cgi and not php-fpm on server because the fpm one seems to work slower for me.... (it's a very old NAS) ...

fastcgi.server = ( ".php" => ("localhost" => 
                        ("bin-path" => "/ffp/bin/php-cgi", 
                        "socket" => "/tmp/php-cgi.socket", 
                        "bin-environment" => ( "PHP_FCGI_CHILDREN" => "0" ), "max-procs" => "1") ) 
                 )

# also had these instruction in my lighty config... don't (yet) what it's for...
server.max-request-size = 65536
server.network-backend="writev"
server.use-noatime = "enable"

 

Edited by PatRoy
Link to comment
Share on other sites

According to the opcache.revalidate_freq setting, your server is only looking for changes to PHP scripts once every minute. I think that is a reasonable amount of time.

Can you do your development and testing locally instead? That really is a good practice to learn, and you should be doing it regardless of this caching thing.

Link to comment
Share on other sites

1 hour ago, requinix said:

According to the opcache.revalidate_freq setting, your server is only looking for changes to PHP scripts once every minute. I think that is a reasonable amount of time.

Can you do your development and testing locally instead? That really is a good practice to learn, and you should be doing it regardless of this caching thing.

 

I just tried changing this setting to '0' and it fixed the issue.... I can't really develop locally, so I'll set this to 0 seconds while I'm developping my project, and change it back to 60 afterwards.

Thanks for your help :))

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.