Picture the scenario:
When running a report via report.php and selecting a date range of say 01st Dec 2016 to 31st Dec 2016 and pressing Run Report or the Enter key I receive:
208 entries found
"THE TABLE OUTPUT"
Showing 1 to 25 of 208 entries
So that all looks correct.
I now want to filter the results by using 'Match brief description:'. I use the word 'age' and run the report and I receive:
3 entries found
"THE TABLE OUTPUT"
Showing 1 to 25 of 208 entries
3 entries found is correct but it still outputs the previous table contents with all 208 entries. If I now press Ctrl + F5 to refrsh the page I get the expected results of:
3 entries found
"THE TABLE OUTPUT"
Showing 1 to 3 of 3 entries
Now if I go to report.php and then search via the date range and the word 'age' at the same time I receive:
3 entries found
"THE TABLE OUTPUT"
Showing 1 to 25 of 381 entries
This appears to be all forward dated entries from the report date as of today rather than the selected date range on the form. Again if I Ctrl + F5 this I get the correct result of:
3 entries found
"THE TABLE OUTPUT"
Showing 1 to 3 of 3 entries
Any ideas welcome!?
I did think maybe this was a caching issue but I have disabled all caching that I know of on the server and no difference. I also tried pushing no-cache via HTTP headers but that also didn't help.
System:
Meeting Room Booking System: MRBS 1.6.1
Database: MySQL 10.0.27-MariaDB-cll-lve
System: Linux ing.co.uk 3.10.0-427.36.1.lve1.4.37.el7.x86_64 #1 SMP Sat Feb 4 07:05:07 EST 2017 x86_64
Server Time: Mon 27 Feb 2017 18:36:13 GMT
PHP: 7.1.2
I think it's a caching issue with the version of js/report.js.php. Can you try running the attached version and see if it fixes the problem?
I think it's the same sort of problem that was being seen with Search in Support Request 1142.
Yes that does sound familiar - I'm just going to check the same things you asked GedM to check and report back.
That fixes it - very quick response - awesome!
Good, glad it's fixed. What I haven't been able to work out is why your system is ignoring the cache instructions on that file. You're going to see a similar problem with Search and also Edit_users (if you use the 'db' authentication scheme), and so you will need these two files as well.
Thanks. Is there anything I can do to try and help at all?
EDIT: The site is fully SSL / HTTPS if that helps spot differences?
Last edit: Alex Haines 2017-02-27
Yes, one thing that would be very useful to know is if you are seeing the same symptoms that we were seeing in 1142 when you use the unmodified version of report.js.php. What does the Cache Expiry date look like in the Response Headers? In 1142 we were seeing something like
instead of
One other to check if you get a chance please. Do you have any mod_expires directives in your site's .htaccess file? For example
It looks to me as though something on the server is inserting Cache-Control and Expires headers. Although mod_expires seems to say that if there are existing Expires headers it won't modify them, it may be that something is going wrong somewhere (possibly because MRBS is issuing its headers in the wrong way and these are actually being appended to the headers issued by the server).
Another test would be to add the following line to the .htaccess file in the MRBS directory:
and then see if you get the problem using the unmodified version of report.js.php.
The .htaccess was pretty simple and just redirected all non ssl traffic to HTTPS along with www to non www.
With the modded .htaccess and the original report.js.php files I now get expected results:
Last edit: Alex Haines 2017-02-27
Assuming within Chrome Developer Tools you meant in Network -> report.js.php -> Response Headers then as follows (otherwise let me know where to look):
Without the modded file:
With the modded file:
Looks like the Expires is duplicated in the unmodded file and then with the modded file it is correctly set it the past.
Last edit: Alex Haines 2017-02-27
What leaps out to be are the "Varnish" headers - your MRBS pages are being served through a Varnish reverse proxy/caching layer, which could undoubtably change expiry behaviour...
I've tried mod_expires on my own vanilla Apache 2.4 configuration, and it works appropriately and only applies Expires headers on URLs which had no Expires header already.
From the test results above it looks like adding
to the .htaccess file solves the problem? In which case is this not the fix for MRBS? That is to add it to the .htaccess file in the MRBS directory?
Looking at 1142's headers (I still have a login) there's no Varnish, though I do see that the server is LiteSpeed.
I set:
and for the Ajax search page mrbs/search.php?search_str=another&day=27&month=2&year=2017&area=10&room=19&datatable=1&ajax=1 I get:
Whereas for a bit of static content (mrbs/jquery/ui/jquery-ui.min.js), I get the expected Expires header:
Yes, but although mod_expires is working correctly on your system, it seems that whatever's happening on Alex's system is cured by turning off ExpiresActive, if I understand it correctly ("With the modded .htaccess and the original report.js.php files I now get expected results:").
Last edit: Campbell Morrison 2017-02-27
Yes that is what I meant.
Last edit: Alex Haines 2017-02-27
Mmm, I wonder if there are particular Apache versions/configurations where mod_expires doesn't work properly for PHP pages defining their own Expires headers.
Maybe. It'll be interesting to see if turning off ExpiresActive also cure's 1142's problem. I'll send a DM.
Another belt and braces fix could be to add the line
to expires_header() if $seconds <= 0?
Interesting, in that the MRBS code for seach.js.php is sending:
but my Chrome Dev Tools are showing:
Where does the "no-cache" come from, and where does the 1981 date come from!?
See http://stackoverflow.com/questions/8194481/why-is-expires-1981
I think what you are seeing are the headers on the Ajax response, which comes from report.php. What I get there are:
As far as I can see the Ajax response is sent without any cache instructions (maybe it should be?). However for report.js.php, I get what I'd expect:
Hi guys,
sorry I have not had a chance to test the vanilla install but I will definately do it tomorrow and get back to you ASAP. I thought it was interesting that the two expire dates in the headers in this bug were 7 days apart.
Expires: Mon, 06 Mar 2017 21:55:32 GMT
Expires: Mon, 27 Feb 2017 21:55:32 GMT
This was the same issue in my headers.
If the vanilla install displays the same behaviour, I will try the htaccess changes you have suggested.
regards
Hi,
I set ExpiresActive Off in the htaccess file and restored the original search.js.php file. The duplicated expires header problem no longer exists.
The duplicated header used to appear on all the .js.php files. They all look correct now.
Thanks
Great - many thanks. Just to be clear - which .htaccess file was that in? Was it in the .htaccess that ships with MRBS and lives in the MRBS directory together with the config file etc.?