Anyway to disable phpbb cache?

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
robbie787
Registered User
Posts: 16
Joined: Fri Sep 13, 2019 12:53 pm

Anyway to disable phpbb cache?

Post by robbie787 »

Is there anyway to disable totally the phpbb cache? I have managed to configure most JS and CSS files by removing asset version code in the theme files such as overall_footer etc. But I can not seem to find the code that declares the following

Forum_fn.js
Ajax.js

and a couple of other theme js files. The whole purpose is to be able to cache the files on cloudflare and cloudflare will not cache the asset version files. I totally understand assets version is for the whole cache system on phpbb but i don't plan on adding new extensions or upgrading them they all work fine.

Is there a way to totally disable the phpbb cache so it turns off versioning? I have tried looking through functions.php but can't seem to find anything that would disable versioning.

Can anyone help with this? It would be really awesome if they could.

User avatar
EA117
Registered User
Posts: 1253
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Anyway to disable phpbb cache?

Post by EA117 »

I expect forum_fn.js and ajax.js to be included in overall_footer.html as most Javascript would. e.g. In prosilver 3.2.8, lines 69 & 70 of /styles/prosilver/template/overall_footer.html:

Code: Select all

<!-- INCLUDEJS forum_fn.js -->
<!-- INCLUDEJS ajax.js -->
The use of the INCLUDEJS directive is what's automatically applying the T_ASSETS_VERSION value to the URL. So you probably want to change those into a non-INCLUDEJS directive include statement, e.g. just a normal HTML <script src=> element you define yourself, using a path built with explicit knowledge of whether the style itself or a parent style is what actually contains this asset.

Note the purpose of the versioning you're removing is to give phpBB a way to help you control your visitors' web browser's caching, and is not "required for phpBB's cache." e.g. If you strip that versioning off the URL and just have the HTML document reference "mysite.tld/assets/stylesheet.css" for example, now whenever you change the contents of stylesheet.css, the only way to "ensure" the user sees the effect of your changes is to ask them to press CTRL-F5 or otherwise clear their web browser's local cache.

By including "?version=x" in this link, and incrementing that version every time a change should be "pushed out", this "forces" any web browsers to download the new "?version=x+1" URL's content. Or at least makes it likely that the web browser will do this, because the web browser's previously-cached version was for the URL ending in "?version=x" and doesn't match the current requested resource URL any more.

There is no "central off switch" I am aware of. The T_ASSETS_VERSION only encapsulates the version value itself, and not "should a version parameter be appended at all." So you have paths already hard-coded in styles which look like "stylesheet.css?version={T_ASSETS_VERSION}", which are in no way going to "drop the version parameter entirely" even if you forced T_ASSETS_VERSION to be a blank value.

robbie787
Registered User
Posts: 16
Joined: Fri Sep 13, 2019 12:53 pm

Re: Anyway to disable phpbb cache?

Post by robbie787 »

Thank you very much for the reply. I will give this a try tomorrow. Hopefully it works.

I thought anything that starts with <!-- in code means that is just information in the code and does not affect anything as it is highlighted green in notepad++ meaning it affects nothing? So if I replace the statements with <!-- to <script src=> and its location it should load from that location without asset version? If I got that correctly.

As with user clearing local cache the files are cached on cloudflare, so if I purge the cloudflare cache it would automatically renew the users browser cache files on next visit so that was never a problem for me.

Cheers for the information. 8-)

User avatar
EA117
Registered User
Posts: 1253
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Anyway to disable phpbb cache?

Post by EA117 »

Indeed it is "just a comment" in HTML-only terms, but has meaning when this HTML document is intended for use as part of a templating framework. They are "comments" so that HTML document contents are effectively "still valid HTML"; but those "comments" have meaning when this document is parsed as a template.

Yes, to have control over whether the version would be placed at the end of the resource path, you are going to replace:

Code: Select all

<!-- INCLUDEJS forum_fn.js -->
with something similar to:

Code: Select all

<script src="/myboard/styles/prosilver/template/forum_fn.js"></script>

User avatar
Gumboots
Registered User
Posts: 216
Joined: Fri Oct 11, 2019 1:59 am

Re: Anyway to disable phpbb cache?

Post by Gumboots »

I know the OP already has a reply for this, but I was looking for the same option but for a different purpose (ie: testing on local). Found it eventually.

Adding this here, as it may be useful for someone: Is it possible to disable cache?

This also seems to greatly speed up hard refreshes on local.

Post Reply

Return to “[3.2.x] Support Forum”