MyBB Community Forums

Full Version: Cache problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I've been facing a very annoying cache problem on my forum. I thought it was related to my hosting but we did everything we could on that end.

Here's the summary:
We were using Cloudflare, and I know CF's cache system can be painful. We thought this problem stemmed from CF so we removed it.
The website was working well, but I couldn't get Global.css changes to show up on the website. I check the file on the FTP, and it is updated with my latest changes, yet the file on the website (or the direct link to that global CSS file) never shows the updated file.
I did everything on my end. Cleared cache, tried proxies, tried different browsers.
The changes are reflected HOURS later. For instance, a code I added yesterday morning is finally here, 24 hours later. Yet I still can't apply new changes.

After we realized the problem wasn't related to CF, we're now back on it. It's in development mode. I purged cache a thousand times. I also continuously rebuild cache on MyBB.
The no-cache header setting is set to Yes.
But I'm now sure that this is related to MyBB.

I'm running MyBB 1.8.24. PHP version is 5.6.40.

My Plugins:
Enhanced Account Switcher, FASTyle, GoMobile, MentionMe, MyAlerts, MyProfile, NewPoints, Template Conditionals, Prostats, QuickReferences, Rin Editor, XThreads, YourCode

This problem is preventing us from coding a new skin for our forum.

In short:
- All cache settings on MyBB are correct (I checked several topics on this forum, and I already applied whatever was recommended there).
- CF cache is disabled (development mode) and purged.
- Global.css file is updated on Admin CP (both with FASTyle and with the normal editor) and the FTP file (it is instantly updated).
- Global.css on the website is never updated.
- The forum with and without "www" gets a different version of the Global.css file but it is never the updated one!

Does anyone know what might cause this?
Are you using nginx ? Or any cache system on your server ?
No, there's only LS Cache and it's inactive. I just checked.
Our hosting provider isn't really helping us with this problem.
Do you think this would resolve if we transferred to another one?
I've previously faced similar problems but they never lasted this long. A simple "clear cache" would resolve it. I understand MyBB loads CSS files in the cache but what I don't get is why I still can't get the version of global.css that is in the FTP with the direct link?
I don't know if I can post links here but here is a picture:
[Image: Untitled-1.png]

The left side is what is seen when I access global.css (e.g. www.forum.com/cache/themes/themeX/global.css)
The right side is the updated file on the CSS.
This particular one was finally updated one day later.
Still, any new changes are not shown on the file. So the problem persists.
<span id="sceditor-start-marker" class="sceditor-selection sceditor-ignore" style="display: none; line-height: 0;"> </span><span id="sceditor-end-marker" class="sceditor-selection sceditor-ignore" style="display: none; line-height: 0;"> </span>No, there's only LS Cache and it's inactive. I just checked.
Our hosting provider isn't really helping us with this problem.
Do you think this would resolve if we transferred to another one?
I've previously faced similar problems but they never lasted this long. A simple "clear cache" would resolve it. I understand MyBB loads CSS files in the cache but what I don't get is why I still can't get the version of global.css that is in the FTP with the direct link?
I don't know if I can post links here but here is a picture:
[Image: Untitled-1.png]

The left side is what is seen when I access global.css (e.g. www.forum.com/cache/themes/themeX/global.css)
The right side is the updated file on the CSS.
This particular one was finally updated one day later.
Still, any new changes are not shown on the file. So the problem persists.
Sorry for the flood.

I had to make sure that the problem is due to MyBB's cache.
I copied the global.css from my theme file (cache/themes) and uploaded it to the MyBB root. It shows the updated file.
The two files are identical, yet when I access the one in the cache folder, it shows the old one.

I also disabled all plugins to see if the problem resolves. It does not. This is due to MyBB's caching system and I don't know how to fix it.

Well, I've managed to solve this myself.

I think it was because of the htaccess file, although there was only a single line of code on it.

I found a recommended one on this forum, and also added a line of code that would redirect all users to "www" version of the forum (because the one without still does not update!)

I still think this is a MyBB bug but maybe the following htaccess code will help other users:

Header set Access-Control-Allow-Origin *

<IfModule mod_mime.c>
    AddType text/css .css
    AddType application/x-javascript .js
    AddType text/x-component .htc
    AddType text/html .html .htm
    AddType text/richtext .rtf .rtx
    AddType image/svg+xml .svg .svgz
    AddType text/plain .txt
    AddType text/xsd .xsd
    AddType text/xsl .xsl
    AddType text/xml .xml
    AddType video/asf .asf .asx .wax .wmv .wmx
    AddType video/avi .avi
    AddType image/bmp .bmp
    AddType application/java .class
    AddType video/divx .divx
    AddType application/msword .doc .docx
    AddType application/vnd.ms-fontobject .eot
    AddType application/x-msdownload .exe
    AddType image/gif .gif
    AddType application/x-gzip .gz .gzip
    AddType image/x-icon .ico
    AddType image/jpeg .jpg .jpeg .jpe
    AddType application/vnd.ms-access .mdb
    AddType audio/midi .mid .midi
    AddType video/quicktime .mov .qt
    AddType audio/mpeg .mp3 .m4a
    AddType video/mp4 .mp4 .m4v
    AddType video/mpeg .mpeg .mpg .mpe
    AddType application/vnd.ms-project .mpp
    AddType application/x-font-otf .otf
    AddType application/vnd.oasis.opendocument.database .odb
    AddType application/vnd.oasis.opendocument.chart .odc
    AddType application/vnd.oasis.opendocument.formula .odf
    AddType application/vnd.oasis.opendocument.graphics .odg
    AddType application/vnd.oasis.opendocument.presentation .odp
    AddType application/vnd.oasis.opendocument.spreadsheet .ods
    AddType application/vnd.oasis.opendocument.text .odt
    AddType audio/ogg .ogg
    AddType application/pdf .pdf
    AddType image/png .png
    AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
    AddType audio/x-realaudio .ra .ram
    AddType application/x-shockwave-flash .swf
    AddType application/x-tar .tar
    AddType image/tiff .tif .tiff
    AddType application/x-font-ttf .ttf .ttc
    AddType audio/wav .wav
    AddType audio/wma .wma
    AddType application/vnd.ms-write .wri
    AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
    AddType application/zip .zip
</IfModule>
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css A31536000
    ExpiresByType application/x-javascript A31536000
    ExpiresByType text/x-component A31536000
    ExpiresByType text/html A3600
    ExpiresByType text/richtext A3600
    ExpiresByType image/svg+xml A3600
    ExpiresByType text/plain A3600
    ExpiresByType text/xsd A3600
    ExpiresByType text/xsl A3600
    ExpiresByType text/xml A3600
    ExpiresByType video/asf A31536000
    ExpiresByType video/avi A31536000
    ExpiresByType image/bmp A31536000
    ExpiresByType application/java A31536000
    ExpiresByType video/divx A31536000
    ExpiresByType application/msword A31536000
    ExpiresByType application/vnd.ms-fontobject A31536000
    ExpiresByType application/x-msdownload A31536000
    ExpiresByType image/gif A31536000
    ExpiresByType application/x-gzip A31536000
    ExpiresByType image/x-icon A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType application/vnd.ms-access A31536000
    ExpiresByType audio/midi A31536000
    ExpiresByType video/quicktime A31536000
    ExpiresByType audio/mpeg A31536000
    ExpiresByType video/mp4 A31536000
    ExpiresByType video/mpeg A31536000
    ExpiresByType application/vnd.ms-project A31536000
    ExpiresByType application/x-font-otf A31536000
    ExpiresByType application/vnd.oasis.opendocument.database A31536000
    ExpiresByType application/vnd.oasis.opendocument.chart A31536000
    ExpiresByType application/vnd.oasis.opendocument.formula A31536000
    ExpiresByType application/vnd.oasis.opendocument.graphics A31536000
    ExpiresByType application/vnd.oasis.opendocument.presentation A31536000
    ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000
    ExpiresByType application/vnd.oasis.opendocument.text A31536000
    ExpiresByType audio/ogg A31536000
    ExpiresByType application/pdf A31536000
    ExpiresByType image/png A31536000
    ExpiresByType application/vnd.ms-powerpoint A31536000
    ExpiresByType audio/x-realaudio A31536000
    ExpiresByType image/svg+xml A31536000
    ExpiresByType application/x-shockwave-flash A31536000
    ExpiresByType application/x-tar A31536000
    ExpiresByType image/tiff A31536000
    ExpiresByType application/x-font-ttf A31536000
    ExpiresByType audio/wav A31536000
    ExpiresByType audio/wma A31536000
    ExpiresByType application/vnd.ms-write A31536000
    ExpiresByType application/vnd.ms-excel A31536000
    ExpiresByType application/zip A31536000
</IfModule>
<IfModule mod_deflate.c>
    <IfModule mod_setenvif.c>
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    </IfModule>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
    <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
    </IfModule>
</IfModule>
<FilesMatch "\.(css|js|htc|CSS|JS|HTC)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag MTime Size
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag MTime Size
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag MTime Size
</FilesMatch>


# Redirect to www
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]