LSCache Mediawiki Plugin

LiteCache

Active Member
#41
I have no idea that the GA plugin can have an influence on the cache function. GA is Javascript based, but you need an HTTP header generated by PHP to influence the cache behavior. Javascript cannot send HTTP headers because it runs in the browser and not on the server. The fact is that if I activate the ad blocker for your site, the caching works. Therefore, logic says that the malfunction is caused by your server or some PHP based function. However, I don't know your installed extensions for GA or GDPR, but that's irrelevant because according to the logic only headers can set what can also set headers. Javascript cannot set headers!
 

LiteCache

Active Member
#43
You don't seem to have understood or wanted to understand anything yet? Sorry, I'm out of this pointless discussion that doesn't help anyone.
 
#44
You don't seem to have understood or wanted to understand anything yet? Sorry, I'm out of this pointless discussion that doesn't help anyone.
Sorry, you mentioned a PHP function, so since I was new to 8.1 I figured I'd switch to some other version to see if that helps.

If it's the server, well, I'm at a loss -- this is a vanilla OLS install.

Have you yourself tested LS Enterprise + Mediawiki with Google Analytics?
 
#47
make clean install of OLS + Mediawiki without any third-party modules or plugins
add LSCache plugin

test.

if work - only than add other plugins and modules.

sometimes order of adding is matter.
I'll give that one a try. I have a bunch of extensions from Mediawiki, which I supposed should not be an issue, but maybe one of them is.
 
#50
in my opinion - Gtag is wrong way for OLS.

LSCache save each page as static html page.

Gtag on each request decide add or not <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX"></script>
Hmm, interesting. That said, the ad tags I had also do the same. Basically any script that sets cookies is likely to do this, no?

Also... why is private cache not hitting? It seems to me if Gtag is adding the tag, then I've consented, I have the cookie, it ought to be serving a private cache to me, but it doesn't.

Finally, what's the right approach? Just force to the script line into LocalSettings? that's how we do ads, I can easily do that with Google Ads insteado f using Gtag, so the script will always be present and not yes/no decided.
 
#52
So, I've given that a try, disabling Gtag. I've done this by using this code from Stackoverflow, putting my own tag ID in, so the code is now placed by default on all pages. It works to put in the tag and cookie... and again, there is no hit, either in public or private cache, when this happens.

FWIW, that's also how I put the ad script in -- via a hook in LocalSettings.php.

I've put in an open issue at the LiteSpeedCache plugin to see if anyone else can verify this behavior.
 
#54
you add $wgHooks to LocalSettings.php?
Correct.

Cache-Control: private, must-revalidate, max-age=0?
Pretty sure that is default Mediawiki.

and cookie ls_smartpush=01 ?
Is this not default OLS? This discussion suggests it is. I can remove it though, it seems. I will try that and see if it changes anything, but it goes out even when the cache is working (no GA script/cookie), so I suspect it won't do anything.
 
Last edited:

LiteCache

Active Member
#55
@Balerion

ls_smartpush cookie doesn't matter in this case. This cookie is set by OLS/LSWS if there is a HTTP/push header, but you don't have any push headers and OLS sets this cookie wrongly with wrong cookie parameters. Anyway, ignore it.

ESI? This doesn't matter as well. Loading an external source like Javascript doesn't need ESI. There seems to be someone who doesn't know what ESI is and what ESI is good for, so ignore such comments.

OLS and LSWS stores dynamically generated sources as a static html source for caching, but LScache doesn't render the HTML Code, so every HTML code that is generated by any Javascript is not cached.
 
#57
Thank you, @LiteCache. I did try the ls_smartpush removal and I'm not sure the directive works in OLS anyways, but no matter, as you say, it wouldn't make a difference.

The code is the standard code I get for manual install of the Google Analytics tag, via the Google Analytics site. The code from Stackoverflow uses the same tag.
 
#59
not sure that function

$wgHooks['BeforePageDisplay'][] = function( OutputPage &$out, Skin &$skin ) {
$code =
in LocalSettings.php is better than Gtag plugin.
The only other option would be to figure out how to place the code in Mediawiki's Common.js, I suppose, but I admit, I do not know how to do that and would have to ask around. But my understanding is that the hook means that before it's done rendering the page, it adds the code, and then it sends it out to users.

I have used that same function to add meta-tags and other things, and none of those cause problems with LSCache. It's only the scripts that add cookies that seem to be at issue.

I am considering getting a trial of LSWS and seeing if maybe it can handle things better.
 
Top