Disable cache on mobile phones

Hello,

When I make changes to a page with cache disabled, the changes are not displayed on mobile devices. From a desktop sometimes it also fails. This happens with cache disabled from the system settings, from the page (cache_enable: false) and even after activating the “Clear cache” button in the side menu of the admin panel.

The changes consist of a change of a photo or a line of text.

It is probably more a lack of knowledge on my part than a Grav problem. As the Grav configuration is so extensive, I guess I’ve made a mistake with the configuration.

I have looked at the documentation and it doesn’t give me much clarification, as I find descriptions similar to those in the panel itself. I have also seen that the configuration options are not exactly the same, so it could be that the documentation is a bit out of date.

Can anyone tell me what settings I should have to ensure that I have completely disabled the cache?

Thank you very much.

disable the cache as a whole is real bad thing to do

Is this a live server or a local development machine ??

If it is a local development machine, you can use the following things

Ensure that your cache setting in the system.yaml is to set to file
and whilst testing a page in the front matter of that page

cache_enabled: false

which attempts to stop the page caching at a page level.

(More for desktop testing of a page)
Also in your browser , if you go to developers tools, and network, there is a “disable cache” setting, which will always force the page to be fetched and no cache version is used, whilst the inspect windows is open

HTH

Thanks @spamhater

Working without cache during web development is not a problem for me. However, I have already set cache_enable: false on the page.

I need to disable the cache on some pages because when their content is updated it has to be modified instantly (a modification of the schedule of a business, for example).

Yep I kind of do the same, and jumping from browser to browser.
You can set in admin for caching not to happen overall, and there is separate frontmatter commands to do this at a per page level

You even have a script running just deleting the root grav install cache folder as cli

Usually what you are asking , is the reverse of what makes grav, well GRAV … lol
disable any php.ini cache loaders at a system level
at grav level disable cache in the system.yaml via editing or using admin with the link as a reference

you can set it to none so to try and stop php caching (from php.ini cache services)

but you setting grav system at a file level, should be good enough for development

further on you can disable twig caching, with grav

then command line level bin/grav cache as a schedule tasked

You will have caching of twig and data , so using the frontmatter on a page level cache_enabled: false

Then you just do a a hard page refresh SHIFT-F5 most browsers or open the browsers devtools/inspector and go to network and disable the browser cache, whilst the inspector is open … and that will stop it at that level

Usually I try and leave it enable on Grav, but setting to file, then have a ramdrive with my webpage cache on it, so easy to get rid of, plus really speeds up the dev experience … and I try and use portable browser, which are sitting of a ramdrive, with an autosync of the critical browser stuff, and their caches with browser switches

My method only works, because I have an APC and 64 GB of ram , so have about an 8 GB ramdrive for windows temp and browser caches being saved in their own directories, saves on thrashing my SSD drive. Then my ramdisk every 5 mins has a task to just sync files of without the temp files / junk. In theory the worst that could happen i loose about 5-10 mins work… when windows spits it dummy out !

Also useful tools for a browser in a extension, which clean the cache and refreshes the page
I like this one for chome based / mozilla browsers the dev is here hxxps://disbug.io/en/app/clear-cache

Then you got a button that dump the browser cache and refresh the page in a single click

Just depends how well you need to scrub up and the hardware you have accessible. :slight_smile:

hi @spamhater for the information and sorry for the delay in my reply.

As I said in the introduction, I have already disabled the cache from the general settings and from the page in question. That works, but it takes a while (especially on mobile phones).

Avoiding the cache for me is simple, what worries me are the users who visit the site: non-technical people who access the site from their mobile phones. These users can’t even type F5… What I want is for them to be able to see the changes made instantly.

The configuration of grav on the cache is very extensive and the documentation does not clarify much the subject. I see types of cache, ways to detect changes, ways to clear the cache (which doesn’t work for me either)… various parameters that I may not know how to combine well in the system configuration.

If someone can help me with this I would appreciate it!

@sdesergi Not a problem, sorry wasnt trying to question your cache… but more of a standard of logical steps.

You say the site is online, could you either drop a link here, or drop a link to the site / page on a direct message. I can have a look and see if there is anything causing it.

It could be some image etc … where it can be sorted with a bit of different markup and using srcset.

Ok that sounds a bit weird if you can clear the cache. Is this via admin or via command line.
What version of grav you using ?

  • Download a backup of your site, or at least backup zip up your user directory and download it.
  • Download the latest version, then remove the user directory
  • Then do a fresh copy of the latest version of grav
  • Rename the user folder to user.old
  • Copy the user directory from your backup to the site.

Cache settings are usually set up with PHP extentsion and grav just use them.
Configuring and enabling zend_opcache as well should show some performance increase.

The docs all go through stuff about production settings for your server and for developement machines , to get the fastest and optimised settings.

Recommended Configuration | Grav Documentation (getgrav.org)

Finally it could be an issue with your host itself, it may not be optimised for bigger pages (PHP) settings.

Check any server logs for errors or things which could be cause a error.

I can talk you through quite a lot of this stuff. Just got to be methodical and test each step, start with the obvious and then go deeper.

HTH and gives you some pointers :slight_smile:

@sdesergi,

When I make changes to a page with cache disabled, the changes are not displayed on mobile devices . From a desktop sometimes it also fails.

I cannot reproduce this. On a fresh install of Grav with default settings, any change to pages Home and Typography are shown in the browser on desktop (Chrome) as well as on my Android phone (Chrome) after a refresh of the browser.

With respect to pages, all Grav does when caching is enabled, is caching the end results of parsing. For example, Markdown needs to be parsed into HTML, Twig needs to be parsed into PHP. Cached files will be regenerated when Grav detects the page file has been changed. Any new request will be served the new cached results.

To get a clearer picture of the problem, some more information/context would be needed.

Questions I have:

  • What theme are you using?
  • What kind of page are you serving? Default, modular, blog?
  • Are you using any Twig inside the page?
  • Which plugins, other then the default plugins, have you installed?
  • How do you make changes to the page? Through Admin, or code editor?
  • Why do you wish to disable the cache? As a workaround, because your page doesn’t seem to be updated in the browser?
  • Do you make use of a CDN?
  • Are you using any HTTP Cache settings?
  • What do you mean by “instantly” in “[…] I want is for them to be able to see the changes made instantly”? Do you perhaps mean without even refreshing the browser?

These users can’t even type F5…".

Also mobile browsers provide a way to refresh the page. At least my Android/Chrome does…

Hello @anon76427325,

Thanks for the explanations. It helps me to understand how it works. I’ve ruled out the points you ask as a possible cause of the problem. I think it’s a simple configuration issue, but I’ll answer it:

  • I use a custom theme made by me, which is a copy of the default theme simplified to the maximum. The theme.php file is intact.
  • The tests are done on a default page, although I’ve called it “page.html.twig”.
  • As additional plugins I 've “image-captions” and “sitemap”.
  • I make the changes through the admin plugin.
  • Yes, I just want the changes to be updated on the fly.
  • I don’t use CDN.
  • I don’t know how to implement http cache. Everything happens on the server, no intermediaries. The http headers configuration has not been modified.
  • Of course, what I want is that the changes happen the next time the web page is opened or refreshed (either with F5 or with a vertical drag from the mobile)

I think the problem may be due to a misconfiguration of the cache on my part. My knowledge of caching is limited and the documentation doesn’t explain much… The last tests I’ve done seem to give me good results, what I’d like to know is why :smiley: So now I can specify the question more precisely:

Does setting all timestamps as a method to check the cache also detect modifications made to the markdown content?

Thanks

The problem has been solved by configuring the HTTP headers cache properly.

As I suspected, I lacked the knowledge to understand how the different caches work with the website. I set the HTTP Cache-Control header to no-cache (which surprisingly does not mean no caching) and enabled the functions provided by grav to identify content changes.

I know it has been a long time since this thread but I like to leave the topics closed.

Thanks @anon76427325 and @spamhater for your attention, you do a great job :slight_smile:

1 Like