I have a PHP script which runs an external process.
The external process outputs a JSON string with data from the system which changes every now and then.
When I run the external process I can clearly see that the JSON string is different every time I run it.
However, when I call my PHP script using AJAX from a web browser the JSON string is not updated after the first call to the PHP script.
The only time the JSON string gets updated is if I refresh the page or run the external process manually while I'm inside the website.
Why is this happening?
Does LIGHTTPD cache the output?
EDIT:
Here's my LIGHTTPD config file content:
server.modules = (
"mod_access",
"mod_cgi",
"mod_alias",
"mod_compress",
"mod_redirect",
# "mod_rewrite",
)
server.document-root = "/var/www"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( "" => "" )
}
cgi.assign = (
".cgi" => ""
)
EDIT
According to the following Google Product thread a person called johnjbarton
mentions the following:
Ok I spoke with a Chrome cache expert. The problem in my case is very likely described on this bug: Bug 30862 - Dynamically inserted subresources aren't revalidated even when the containing document is reloaded https://bugs.webkit.org/show_bug.cgi?id=30862
The force-refresh only forces resource loaded in the outer page. It does not force refresh on XHR loaded resources. Which is pretty much all of the resources in a dojo app.
When I look at the console of chrome under the Network
section it says
that all of the requests that my website is making are of type XHR
.
Can this be somehow related?
EDIT
The headers of my request are
Accept */*
Content-Type application/x-www-form-urlencoded
VERY IMPORTANT EDIT I edited my PHP script so that it appends the results of the process it executes in to a log file.
It turns out that the output of the process always is the same.
However when I run the process manually it constantly changes as expected.
It seems to me as if LIGHTTPD is caching the output of the process that it executes.
EDIT
This is what my PHP script looks like:
<?php
session_start();
if(!isset($_SESSION['user'])){
header("Location: /");
} else {
header('Content-type: application/json');
$output = shell_exec('/home/debian/myProcess/myProcess');
file_put_contents("/var/log/lighttpd/access.log", $output, FILE_APPEND | LOCK_EX);
echo $output;
}
?>