Not Solved CSS style sheet changes not appearing (cache issue?)
#1
Not Solved
Hi folks - I made one small change to the extra CSS sheet, however it is not appearing upon load.

The change isn't reflected in the /cache folder of the website.  I've tried all sorts of browser forced reloads, but the cache isn't changing.  I am not using cloudflare.  I've already rebuilt the cache through the admin console.  Not sure how to force a cache refresh, any suggestions?  I am running 1.8.12.
Reply
#2
Not Solved
What's your URL and what was the change you made?

Also you should upgrade as soon as you can, 1.8.12 was released over 4 and a half years ago and there have been 15 security releases since.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#3
Not Solved
And if you're using nginx, it has a built-in cache. force-reload nginx to clear it
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM or Discord
Reply
#4
Not Solved
I edited the extra.min.css stylesheet (I made one small change to a color hex). I'm paranoid so don't want to share the URL at the moment anyway.

I've confirmed that for a brand new user who has never been to my site, the color fix is loaded correctly. My issue is that I can't seem to force a cache reload for those who have already been to the site.

I'm not sure if I am using nginx.. I am using shared hosted on bluehost (sorry for the rookie response). Appreciate any guidance..

Is it possible I could fix this by turning off caching age inside the .htaccess file?
Reply
#5
Not Solved
When you make a change in a CSS file, you can force the refresh by appending the src with a variable. Example here:
<link type="text/css" rel="stylesheet" href="https://community.mybb.com/cache/themes/theme6/global.min.css?t=1623969169" />

The t=1623969169 is a part forcing the reload, as you can change it without any repercussion on CSS. Or you can add &ver=1234 (or any parameter). Browsers will think it's a new file (as url is different) and then load from server rather than use its cache
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM or Discord
Reply
#6
Not Solved
Crazycat, thanks for the great help. One more question - which file contains the src that references the CSS files?

I've tried to figure out out myself this afternoon to no avail. I did find this thread (https://community.mybb.com/thread-195622.html) but I am just hoping to directly edit whichever file and append with a variable, as you recommended. Thank you for your help.
Reply
#7
Not Solved
I note that 1.8.29 includes timestamp references in stylesheets.
Global.php is the core code that initializes {$stylesheets}, and this line is the one that adds the stamp.
338                          $stylesheet_url .= "?t=".filemtime(MYBB_ROOT.$page_stylesheet);

I'm not sure what version introduced timestamp references, but an upgrade, while laborious, has many advantages.

Pagesource before a global.css edit:
<link type="text/css" rel="stylesheet" href="https://mydomain.com/forum/cache/themes/theme13/global.css?t=1620208166" />
<link type="text/css" rel="stylesheet" href="https://mydomain.com/forum/cache/themes/theme13/css3.css?t=1618658896" />
<link type="text/css" rel="stylesheet" href="https://mydomain.com/forum/cache/themes/theme1/converse.css?t=1642016597" />

Pagesource after an edit:
<link type="text/css" rel="stylesheet" href="https://mydomain.com/forum/cache/themes/theme13/global.css?t=1642251336" />
<link type="text/css" rel="stylesheet" href="https://mydomain.com/forum/cache/themes/theme13/css3.css?t=1618658896" />
<link type="text/css" rel="stylesheet" href="https://mydomain.com/forum/cache/themes/theme1/converse.css?t=1642016597" />

Timestamps were introduced in 1.8.27

Comparing global.php versions 1.8.12, .26, and .27 suggests you may be able to achieve the same result by adding this code.
					if (file_exists(MYBB_ROOT.$page_stylesheet))
					{
						$stylesheet_url .= "?t=".filemtime(MYBB_ROOT.$page_stylesheet);
					}

after your version's line 337 which reads
					$stylesheet_url = $mybb->get_asset_url($page_stylesheet);

This is an untested remedy. There may be other code changes required which support this feature, so be prepared to revert your global.php if it does not work.
Reply
#8
Not Solved
I implemented your changes exactly as suggested and BOOM - it worked!!!!!!!!

*THANK YOU HLFadmin!!*

I'm really grateful to have this working. I'll do some additional testing but it's looking good so far.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)