MCBBS Wiki:运维笔记:修订间差异

添加1,116字节 、​ 2023年6月20日 (星期二)
→‎移动端缓存:​ // Edit via Wikiplus
→‎Varnish:​ // Edit via Wikiplus
→‎移动端缓存:​ // Edit via Wikiplus
 
(未显示同一用户的7个中间版本)
==Varnish==
首先,要确保 Varnish 相关缓存逻辑正常工作,必须在 LocalSettings.php 设置 <code>$wgUseCdn = true;</code>
 
同时,指定<code>$wgInternalServer</code> 为 Wiki 的域名加 Varnish 监听端口。(如 <code>$wgInternalServer = "http://example.org:6081";</code>)。
 
并且 MediaWiki 给出的 [[mw:Manual:Varnish_caching#Configuring_Varnish|vcl 规则]]已适用于大多数情况。
===Parsoid 405===
若编辑部分页面时出现<code>连接至Parsoid/RESTBase服务器错误(HTTP 405)</code>
 
配置以下 vcl 规则至<code>sub vcl_recv</code>中,直接请求 api.php 和 rest.php 不经过缓存。
<pre>if (req.url ~ "api.php" || req.url ~ "rest.php")
return (pass);
 
即可实现仅登录用户启用 Popups 。
===HTTP 反向代理模式下 PURGE 请求===
方案来自于 Mooncell Wiki 的[https://www.bilibili.com/read/cv17391941 这篇]专栏。
 
MediaWiki 默认情况下,页面更新时会发送 PURGE 代理请求 Varnish 清理缓存。这仅适用于 Varnish 被配置为 HTTP 正向代理模式时。
 
如果 Varnish 在 HTTP 反向代理模式下工作,编辑 <code>includes/deferred/CdnCacheUpdate.php</code> 的 304297 行:
<pre>$reqs[] = ( $baseReq );</pre>
以及 297 行:
<pre>'Host' => $urlInfo['host'],</pre>
以及 297304 行:
<pre>$reqs[] = ( $baseReq );</pre>
 
即可实现只通过 HTTPMediaWiki Varnish HTTP 反向代理模式下发送 PURGE 缓存清理请求。
===移动端缓存===
如果移动版页面和桌面版使用同一个域名,添加以下规则:
 
<code>sub vcl_recv</code>中:
<pre> remove req.http.x-subdomain;
if(req.http.User-Agent ~ "(?i)^(lg-|sie-|nec-|lge-|sgh-|pg-)|(mobi|240x240|240x320|320x320|alcatel|android|audiovox|bada|benq|blackberry|cdm-|compal-|docomo|ericsson|hiptop|htc[-_]|huawei|ipod|kddi-|kindle|meego|midp|mitsu|mmp\/|mot-|motor|ngm_|nintendo|opera.m|palm|panasonic|philips|phone|playstation|portalmmm|sagem-|samsung|sanyo|sec-|sendo|sharp|softbank|symbian|teleca|up.browser|webos)") {
set req.http.x-subdomain = "m";
}
 
if(req.http.Cookie ~ "mf_useformat=") {
即可实现只通过 HTTP 向 Varnish 发送 PURGE 缓存清理请求。
set req.http.x-subdomain = "m";
}</pre>
<code>sub vcl_hash</code>中:
<pre>hash_data(req.http.x-subdomain);</pre>
以实现桌面端和移动端页面的分别缓存。
 
==本地化文字修改==
维护员、​界面管理员、​巡查员、​监督员、​小部件编辑者
3,462

个编辑