Firefox PHP

Caching issue.

Posted by stargazer77 
Caching issue.
August 19, 2020 03:47PM
I'm very close to having everything working now, but a big issue I'm seeing is things are not working right with the caching of the site in some way. I have all caching options disabled in admin, yet for whatever reason, pages are getting cached and it is causing problems.

When I submit a new post, it doesn't show up on the forum page until I hit CTRL-F5. When I save a setting in the admin area and go to the page to make sure it saved, it shows the old setting until i hit CTRL-F5. When I'm on the site, I have the New Count module installed, and it shows the number of New messages. I go in the thread, click all messages and then go to the main forum page and it is still showing the same number of New messages until I hit CTRL-F5.

Any suggestions for stopping it from caching in this way? This is going to make it very difficult for end users if they have to repeatedly hit CTRL-F5 to see their new posts and new posts from others.
Re: Caching issue.
August 19, 2020 09:43PM
Ctrl F5 tells the browser to get a new copy.

Most browsers that support Web Development, will allow you to disable the browser cache.

Google... cache-control: must-revalidate
web server cache directives

What is the Cache-Control Header
So how do I get it to stop on this site?
August 20, 2020 01:26AM
I post regularly on another site using Phorum and it doesn't do this there. I have no idea why it is doing it on the site I'm setting up. It did not do this on my previous effort at setting up a Phorum site so this is entirely new to me. Someone that is working on testing with me that also posts at that same other site is saying it is happening to him on the site we're trying to set up as well so it's not just my browser.

I'd rather have no caching whatsoever than to risk having to force end users to hit CTRL-F5 in order to see newly posted content.

I'm comparing the source code within the head area on the post pages for the two sites. I'm seeing the one that doesn't have the caching problem has the following code present that is not present on the site I'm setting up:


Language: HTML
<meta name="robots" content="NOINDEX,NOFOLLOW">

I don't know if that would have any relevance to my issue or not. There is another script present in the other site that I'll post next after getting your thoughts on the above meta tag. I don't know javascript coding myself, so I'm not sure what's needed here.
Re: Caching issue.
August 20, 2020 02:43PM
After some further reading, I found this page:

https://stackoverflow.com/questions/4480304/how-to-set-http-headers-for-cache-control

I decided to try to add

Language: HTML
<meta http-equiv="Cache-control" content="no-store">

That didn't work.

But then I tried

Language: HTML
<meta http-equiv="Cache-control" content="no-store" />

and I think that may have done it. More testing to come for me to fully confirm that it is working, but it worked on my first test post.

I used no-store here just to get it to where it forces the load from the server all the time just to see it working. Now I can try to set it using "must-revalidate" to allow caching if there is nothing new on the page but not allow caching if there is anything new on the page.

Am I understanding that option correctly?

The problem there is on the page I linked above "must-revalidate" isn't one of the options available with the syntax provided.
Re: Caching issue.
August 20, 2020 03:28PM
On subsequent testing, I'm seeing that it works on my admin account in Firefox, but it's still not working on a non-admin account in Google Chrome. This is very frustrating. I thought I had it. Any further suggestions?

More testing to come.
Re: Caching issue.
August 20, 2020 03:38PM
Now I'm seeing that it is no longer working on the admin account in Firefox either. Messages flagged as New by the New Count module are still showing as New even after they are read, until I hit CTRL-F5. Then they are no longer counting as new.

I also tested Private Messages. The flag saying you have new private messages shows, I click through to read the message, then when I go back to the forum page, it's still saying I have new private messages until I hit CTRL-F5.

I'm at a loss as to how to stop this. That makes no sense that it briefly seemed to work and now it is right back to not working at all. Even in the admin account in Firefox, new threads are again not showing up on the main forum page until after I hit CTRL-F5.

Note too that the problem is not limited to the public boards. It's doing the same thing in the admin area as well. I have to hit CTRL-F5 for settings changes I've made to show properly on subsequent admin page loads.



Edited 2 time(s). Last edit at 08/20/2020 04:09PM by stargazer77.
Re: Caching issue.
August 20, 2020 05:53PM
Here's something else about the issue. I have all cache settings set to No in the admin area. But when I go to Purge Cache and execute that, it's saying cached files were purged and showing an amount of files. Shouldn't it say there were no files cached if I have everything set to No? Something is messed up. This site is running on PHP 7.3 if that makes a difference. I can only drop that down to PHP 7.0 on this host. Should I try that in case 7.3 is breaking something?
Re: Caching issue.
August 20, 2020 10:01PM
There are cache files that are not controlled by the admin, by design. These are the files that rarely change, like templates.
Re: Caching issue.
August 20, 2020 10:45PM
I think caching headers may also be sent/controlled using a setting in .htaccess, or Microsofts equivalent if on a Windows server.
Re: Caching issue.
August 21, 2020 01:58AM
OK, going the .htaccess route, there isn't an .htaccess file in the root phorum folder. What we have is a Wordpress installation in the root folder (public_html), then the phorum folder is off the root (public_html/phorum/). Looking in the root folder, there is an .htaccess file there with the following contents.


# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_expires.c>
	ExpiresActive On
	ExpiresByType image/jpg "access plus 1 year"
	ExpiresByType image/jpeg "access plus 1 year"
	ExpiresByType image/gif "access plus 1 year"
	ExpiresByType image/png "access plus 1 year"
	ExpiresByType text/css "access plus 1 month"
	ExpiresByType application/pdf "access plus 1 month"
	ExpiresByType text/javascript "access plus 1 month"
	ExpiresByType text/html "access plus 5 minutes"
	ExpiresByType image/x-icon "access plus 1 year"
	ExpiresDefault "access plus 6 hours"
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
</ifModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Could that be the cause of the problem? Would that file in the root folder impact what's happening in the phorum folder?

Is there a counter for that which I could put in an .htaccess file in the phorum folder to test? I also could try uninstalling Wordpress from the root directory as well if you think that will help.
Re: Caching issue.
August 21, 2020 02:33AM
I think this may have done it. It's working on initial tests in both Firefox and Chrome.

What I did was delete the Endurance Cache mu-plugins that existed in the Wordpress installation. I found some material online that my host was adding that on their own and that it could be safely removed.

Then I made a copy of this .htaccess file, and modified the HTML line and the default line to make them "access plus 0 seconds" as follows:

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_expires.c>
	ExpiresActive On
	ExpiresByType image/jpg "access plus 1 year"
	ExpiresByType image/jpeg "access plus 1 year"
	ExpiresByType image/gif "access plus 1 year"
	ExpiresByType image/png "access plus 1 year"
	ExpiresByType text/css "access plus 1 month"
	ExpiresByType application/pdf "access plus 1 month"
	ExpiresByType text/javascript "access plus 1 month"
	ExpiresByType text/html "access plus 0 seconds"
	ExpiresByType image/x-icon "access plus 1 year"
	ExpiresDefault "access plus 0 seconds"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Initial tests are working. But I've seen things seemingly work before and then reverted back to not working. So I'm cautiously optimistic here. This does feel like it is the correct fix though. Several others reported countless wasted hours spent trying to diagnose caching problems stemming from this being automatically installed by the webhost with a Wordpress installation. That feels like what I just went through.

I'll test some more but fingers crossed that this is it.
Re: Caching issue.
August 21, 2020 02:54AM
I would attempt to put an .htaccess file in the Phorum directory that does what you need/want for Phorum.
Sorry, only registered users may post in this forum.

Click here to login