UnCache by ReFlar

License Latest Stable Version

No more cache related problems! Automatically clear the cache when you enable a new extension.

Usage

  • Cache will be cleared when you enable any future extensions
  • Optional Cloudflare cache clearing support
  • Users are forced to drop their cache when new js or css files are available on the server
  • Translations will work immediately when extensions are enabled
  • A button is available to manually clear the cache on the extension's admin page. This is useful for when you update an extension, or if you don't have ssh access.

Installation

Use Bazaar or install manually with composer:

composer require reflar/uncache

Then login and enable the extension.

Issues

Links

Fun fact: this is the third extension to be released today!

    This does not solve the users having to clear their own cache, correct?

      MikeJones it does! When you enable an extension or manually click the button on the admin page, it will force each user to drop their cached files and grab the new ones from the server. From the user's perspective absolutely nothing happens, they can't even see the refresh.

        Kyrne

        The connection to cloudflare does not work

        debug

        POST https://forum.oxidepolska.eu/api/uncache/invalidate
        
        {
          "errors": [
            {
              "code": 500,
              "title": "Internal server error",
              "detail": "InvalidArgumentException: Flarum\\Api\\Serializer\\UserSerializer can only serialize instances of Flarum\\Core\\User in /var/www/flarum/vendor/flarum/core/src/Api/Serializer/UserBasicSerializer.php:33\nStack trace:\n#0 /var/www/flarum/vendor/flarum/core/src/Api/Serializer/UserSerializer.php(36): Flarum\\Api\\Serializer\\UserBasicSerializer->getDefaultAttributes(Object(stdClass))\n#1 /var/www/flarum/vendor/flarum/core/src/Api/Serializer/AbstractSerializer.php(71): Flarum\\Api\\Serializer\\UserSerializer->getDefaultAttributes(Object(stdClass))\n#2 /var/www/flarum/vendor/tobscure/json-api/src/Resource.php(169): Flarum\\Api\\Serializer\\AbstractSerializer->getAttributes(Object(stdClass), NULL)\n#3 /var/www/flarum/vendor/tobscure/json-api/src/Resource.php(75): Tobscure\\JsonApi\\Resource->getAttributes()\n#4 /var/www/flarum/vendor/tobscure/json-api/src/Document.php(181): Tobscure\\JsonApi\\Resource->toArray()\n#5 /var/www/flarum/vendor/tobscure/json-api/src/Document.php(224): Tobscure\\JsonApi\\Document->toArray()\n#6 /var/www/flarum/vendor/flarum/core/src/Api/JsonApiResponse.php(29): Tobscure\\JsonApi\\Document->jsonSerialize()\n#7 /var/www/flarum/vendor/flarum/core/src/Api/Controller/AbstractSerializeController.php(112): Flarum\\Api\\JsonApiResponse->__construct(Object(Tobscure\\JsonApi\\Document))\n#8 /var/www/flarum/vendor/flarum/core/src/Http/Handler/ControllerRouteHandler.php(53): Flarum\\Api\\Controller\\AbstractSerializeController->handle(Object(Zend\\Stratigility\\Http\\Request))\n#9 /var/www/flarum/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php(69): Flarum\\Http\\Handler\\ControllerRouteHandler->__invoke(Object(Zend\\Stratigility\\Http\\Request), Array)\n#10 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Http\\Middleware\\DispatchRoute->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#11 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\DispatchRoute), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#12 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#13 /var/www/flarum/vendor/flarum/core/src/Http/Middleware/SetLocale.php(51): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#14 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Http\\Middleware\\SetLocale->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#15 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\SetLocale), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#16 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#17 /var/www/flarum/vendor/flarum/core/src/Http/Middleware/AuthenticateWithHeader.php(58): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#18 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Http\\Middleware\\AuthenticateWithHeader->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#19 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\AuthenticateWithHeader), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#20 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#21 /var/www/flarum/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(36): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#22 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Http\\Middleware\\AuthenticateWithSession->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#23 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\AuthenticateWithSession), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#24 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#25 /var/www/flarum/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(39): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#26 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Http\\Middleware\\RememberFromCookie->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#27 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\RememberFromCookie), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#28 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#29 /var/www/flarum/vendor/flarum/core/src/Http/Middleware/StartSession.php(48): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#30 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Http\\Middleware\\StartSession->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#31 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\StartSession), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#32 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#33 /var/www/flarum/vendor/flarum/core/src/Api/Middleware/FakeHttpMethods.php(33): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#34 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Api\\Middleware\\FakeHttpMethods->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#35 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Api\\Middleware\\FakeHttpMethods), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#36 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#37 /var/www/flarum/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(31): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#38 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Http\\Middleware\\ParseJsonBody->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#39 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\ParseJsonBody), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#40 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#41 /var/www/flarum/vendor/flarum/core/src/Api/Middleware/HandleErrors.php(45): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#42 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(212): Flarum\\Api\\Middleware\\HandleErrors->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#43 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Api\\Middleware\\HandleErrors), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#44 /var/www/flarum/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#45 /var/www/flarum/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php(111): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#46 /var/www/flarum/vendor/flarum/core/src/Http/AbstractServer.php(55): Zend\\Stratigility\\MiddlewarePipe->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\NoopFinalHandler))\n#47 /var/www/flarum/vendor/zendframework/zend-diactoros/src/Server.php(157): Flarum\\Http\\AbstractServer->__invoke(Object(Zend\\Diactoros\\ServerRequest), Object(Zend\\Diactoros\\Response), Object(Zend\\Stratigility\\NoopFinalHandler))\n#48 /var/www/flarum/vendor/flarum/core/src/Http/AbstractServer.php(36): Zend\\Diactoros\\Server->listen(Object(Zend\\Stratigility\\NoopFinalHandler))\n#49 /var/www/flarum/api.php(16): Flarum\\Http\\AbstractServer->listen()\n#50 {main}"
            }
          ]
        }

        info

        Flarum core 0.1.0-beta.7
        PHP 7.1.17-1+0~20180505045956.17+jessie~1.gbpde69c6
        Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, pcntl, Reflection, SPL, session, standard, mysqlnd, PDO, xml, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, json, exif, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, Zend OPcache
        EXT flarum-akismet v0.1.0-beta.6
        EXT flarum-approval v0.1.0-beta.7
        EXT noriods-auto-more 0.2.0
        EXT zaptech-cookie-consent 0.1.0-beta3
        EXT datitisev-dashboard v0.1.0-beta.7
        EXT flarum-emoji v0.1.0-beta.6
        EXT clarkwinkelmann-emojionearea 0.1.2
        EXT flarum-english v0.1.0-beta.7
        EXT flagrow-split 0.2
        EXT flagrow-upload 0.6.0
        EXT flarum-flags v0.1.0-beta.7
        EXT sijad-recaptcha 0.0.2
        EXT flarum-likes v0.1.0-beta.6
        EXT sijad-links 0.1.0-beta.6
        EXT flarum-lock v0.1.0-beta.7
        EXT flarum-markdown v0.1.0-beta.5
        EXT ganuonglachanh-markdown-editor 0.9
        EXT flarum-mentions v0.1.0-beta.7
        EXT antoinefr-money 0.5.0
        EXT flarum-pusher v0.1.0-beta.6
        EXT reflar-nightmode 0.1.5
        EXT reflar-uncache 0.1.0-beta.1
        EXT terabin-sitemap v1.0.2-beta.2
        EXT sijad-auth-steam 0.1.10
        EXT flarum-sticky v0.1.0-beta.7
        EXT flarum-subscriptions v0.1.0-beta.6
        EXT flarum-suspend v0.1.0-beta.7
        EXT flarum-tags v0.1.0-beta.8
        Base URL: https://forum.oxidepolska.eu
        Installation path: /var/www/flarum

          Nice job, I'll need to try it out.

          Suggestion: only clear assets files from Cloudflare cache (like you unlink them from filesystem) instead of the whole domain cache. Maybe this could be an option so you can still clear everything if you need.

          Also there's a strange backslash here https://github.com/ReFlar/UnCache/blob/6e80c99f8d71d7687f78de2841536e0877457733/src/Jobs/ClearCache.php#L87 (I'd expect a slash, but it's possible both work anyway)

            Hell yeah, great job, I am definitely going to test it! ♥

            Many thanks bro ♥ ! I think it will solve most of my problems with caching.

            clarkwinkelmann It already does only clear the asset files! Take a look at the code if you want to confirm.

            youhosi oops, I'll fix that today. This isn't an error in functionality, so rest assured, the assets are still be cleared even while getting that error.

            0.1.0-beta.2

            • Fixes a serialization problem with the Cloudflare data youhosi
            • Fixes slash issues. I develop on windows so I used backslash, it will now check for your platform and use the correct slash clarkwinkelmann m4rny
            • Added some friendly warnings for situations:
              • Cloudflare doesn't have your asset files cached
              • You tried to clear the cache twice

            Updating ⬆

            1. Click the "Clear Cache" button then refresh (This is so much easier than commands right?)

            Please allow Bazaar 60 minutes to pull the update

              Kyrne Wow that was fast. You shouldn't be considered a Contributor, they need to make a Superhero group, and you should be in it!

                Kyrne So to update this extension I don't have to use SSH at all? I just have to click the clear cache button in the extension on my admin console?

                  Frink I guess I just read that post wrong... Whats the command for updating then?

                    MikeJones composer update, same as always. Reflar UnCache just fixes the hassle of clearing the cache, etc.

                      Frink gotcha, this is the first extension I am updating. That command I am assuming looks for updates for all extensions I have installed?

                      Thanks!