Page MenuHomePhabricator

Is there anyway to convert Cache-Control header in pages from private to public?
Closed, ResolvedPublic

Description

Hi,

The Cache-Control header for Mediawiki pages was designed to be : private, s-maxage=0, max-age=0, must-revalidate since 2005 or even earlier, for each page to show anonymous user's IP, which is documented here: https://wikitech.wikimedia.org/wiki/MediaWiki_caching#Cache_headers. Such desgin does make sense with the old design that show user's IP for each user.

However, The display of anonymous user's IP was removed in Mediawiki 1.27 in 2015. Therefore every anonymous users now get exactly same page. Changing the Cache-Control header from private to public make more sense now, where we could utilized the caching ability of CDN (such as Cloudflare) to reduce server load. We found some complain about the private header from webplatform as well: https://webplatform.github.io/docs/WPD/Infrastructure/architecture/Things_to_consider_when_we_expose_service_via_Fastly_and_Varnish/ .

Is there anyway to convert Cache-Control header in pages from private to public?

Best Regards,

Event Timeline

Zoglun created this task.Mar 5 2019, 2:13 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 5 2019, 2:13 PM

Is this a bug report (if it is, what is the bug?) or a support question?

Zoglun added a comment.Mar 5 2019, 3:13 PM

Is this a bug report (if it is, what is the bug?) or a support question?

I am not sure the "private" cache header is a feature or just an ancient setting now become a bug. It either should be set to default "public", or offer a $wg setting variable to change the Cache-Control header. Either way will work better than send "private" no matter user login or not.

Krinkle moved this task from Backlog to HTTP Cache proxy on the MediaWiki-Cache board.EditedJul 15 2019, 10:42 PM
Krinkle added a subscriber: Krinkle.

The ways that a logged-out page view can vary. have had configuration variables. Two of which still exists:

  • IP-address in personal header: This used to be configurable by $wgShowIPinHeader. It was disabled on Wikipedia, but still existed as an option in MediaWiki. This feature was removed in 2016 (T127758, https://gerrit.wikimedia.org/r/239649).
  • Developer toolbar: Configurable via $wgDebugToolbar.

Both today and before 2016, these features are automatically disabled if you use a CDN (whether our own cache proxy, like Wikipedia does, or an external one). To tell MediaWiki you're using using a CDN, set $wgUseCdn. See also https://www.mediawiki.org/wiki/Manual:Performance_tuning#Page_view_caching.

See also $wgEnableSidebarCache, which you'll probably want to enable.

Krinkle closed this task as Resolved.Jul 15 2019, 10:45 PM
Krinkle claimed this task.
Krinkle triaged this task as Normal priority.

I believe this resolves the issue in question (as such, more a support question than a bug report). Feel free to re-open if it doesn't work as expected.

See also https://www.mediawiki.org/wiki/Project:Support_desk and Discourse which may be ways to get support quicker (e.g. if you're unsure whether it's a bug).