A Detailed Introduction to Flarum Caching and How to Clear the Cache
The cache issues in the beta version of Flarum are the main cause of various errors in this forum application, such as nojs, changes to the styles in the admin panel not being reflected on the frontend, and errors when switching languages, displayed as xxx.xxx.xx. Below, I will explain Flarum's caching mechanism in detail.
Flarum's cache consists of three major parts:
Main Cache (the main cause of most nojs pages)
Introduction: These are the combined JS and CSS files generated by the forum that support the entire Flarum website. When debug is disabled (the default), they are compressed; when debug is enabled, they are uncompressed.
Location: The admin-xxx.css, admin-xxx.js, forum-xxx.js, and forum-xxx.css files, as well as rev-manifest.json, in the /assets directory.
Purpose: As the names suggest, the two files beginning with admin represent the JS and CSS files for the admin panel, while those beginning with forum represent the JS and CSS files for the website frontend. rev-manifest.json records the names of these four files. When the website is opened, it sends a request to rev-manifest.json to obtain the corresponding CSS and JS files.
Clearing: The official recommendation is to cd to the website root directory and enter php flarum cache:clear to clear the cache. However, this command does not delete rev-manifest.json, and some extensions require you to manually delete the rev-manifest.json file after clearing the cache.
Storage Cache (one of the main causes of some nojs pages)
Introduction: These are the cache files generated the first time Flarum runs (JS, CSS, and other files extracted from the system and extensions and stored separately under /storage in the root directory), after which the CSS and JS are combined into the main cache described above.
Location: The cache, formatter, less, locale, tmp, views, and other folders under the /storage directory.
Purpose:
- cache: General cache containing various cache contents used by the forum in compressed, separate form. If something does not work or nojs appears after you enable an extension, and clearing the main cache has no effect, delete all the files in this folder. This generally solves the problem.
- formatter: BBCode cache. If you have added custom BBCode (including adding or editing the
flarum-ext-mediaembedextension for online video), be sure to manually delete the files in this folder. - less: As the name suggests, all Less cache used by the forum (Less is, simply put, an advanced version of the CSS language, and all of Flarum's CSS is generated by Less). If style errors occur after enabling or disabling an extension, you can consider deleting all the files in this folder.
- locale: After switching to Chinese, if titles, buttons, and similar elements all display xx.xxxx.xxxx, don't think too much about it—delete all the files in this folder. It is used to cache language files.
- tmp: Temporary forum cache, which is normally cleared automatically.
- views: View cache, containing cached CSS, HTML, and other content.
Browser Cache
There is not much to explain here. Basically, every time you clear the cache, you need to press Ctrl + F5 to refresh the browser page, because Flarum does not automatically update the browser cache after you make changes.
In summary, the many problems with Flarum are mainly caused by Flarum's caching mechanism. There are many places where cache is stored, and the various caches may fail to refresh synchronously due to various issues. Of course, if you do not change the admin settings after installing the forum (especially extension switches or extension settings), Flarum remains rock-solid.
Comments
(0)No comments yet. Start the conversation.