Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[site-toolbox] Does premium plugin warm cache work with login plugin #441

Open
Japhys opened this issue May 22, 2024 · 2 comments
Open

[site-toolbox] Does premium plugin warm cache work with login plugin #441

Japhys opened this issue May 22, 2024 · 2 comments
Assignees
Labels
site-toolbox Site Toolbox bundle

Comments

@Japhys
Copy link

Japhys commented May 22, 2024

Hi,

I would like to purchase the warm cache plugin but have some questions.

I have a single instagram like page with a 1000+ high quality images. I am actually quite surprised how well this works, they load very very fast still. There is only one problem. When I do an CMS update, cache is emptied. When loading the photo page afterwards it runs out of memory a couple of times before the page finally loads. In the admin panel it also takes forever for the page with attachments thumbnails to load. Now I can make sure the cache doesn’t get deleted by renaming the folder during update but that is a hassle.

My photo page is behind a login.

My questions:

  • will this work behind a login?
  • if it runs out of memory, will this halt the caching process altoghether?

Any other ideas how to handle this are very welcome as well.

Info setup

VPS 4 cores | 8 GB
Ubuntu 22.04 / Docker / Ngninx proxy manager

Grav v1.7.46 - Admin v1.10.46
Login plugin v3.7.9

version: "2.1"
services:
  grav:
    image: lscr.io/linuxserver/grav:latest
    container_name: grav
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Amsterdam
    volumes:
      - /srv/grav/config:/config
    ports:
      - 7400:80
    restart: unless-stopped

@Japhys Japhys added the site-toolbox Site Toolbox bundle label May 22, 2024
@rhukster
Copy link
Member

Warm cache uses the sitemap and then iterates over the pages it finds, and simply using a web crawler to hit the page (therefore causing any images to be processed and cached). If you have a page that is protected by the login plugin, warm cache will get blocked by the login form just like a regular user.

I can envision a couple of ways to get around this.

  1. create a dummy page with the same images, that is an obscure unguessable URL. Make sure its routable, but also configure it so that it's ignored by the sitemap. You could even add a rule in your webserver or firewall (or cloudflare if you use it) to block all access to this page except for the browseragent associated with Grav's sitemap crawler.

  2. create a custom plugin that hooks into the login event hooks and checks the sitemap crawler's browser agent and automatically gives access if that agent is found. Can customize the broser agent string in the sitemap plugin to pick something secure.

Both of these are non-trivial, in that they will need some setup and/or some simple programming skills i'm afraid. Anything is possible, but not everything is possible in a nice GUI way of doing things..

The other issues about timesouts and memory can be offset by increasing both in your php.ini file.. but other than that, the only way to handle things is:

a) use another service to resize the images (like imagekit, cloudflare images, etc).. these 3rd party image resizing services will not impact the performance of Grav at all as they resize dynamically with each image request.

b) break up your output so that you don't show 100 at a time, only show 20 perhaps, then paginate the rest. If you are using instagram feed plugin, it maybe possible to modify the Twig and add some JS to to paginate results. I've not and the need to do this before, so i'm just spitballing.

@Japhys
Copy link
Author

Japhys commented May 29, 2024

Than you! These are very useful tips. Option one is actually good enough for me and should be pretty easy to do. I have a try!

As for the memory, I will see what I can achieve with php.ini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site-toolbox Site Toolbox bundle
Projects
None yet
Development

No branches or pull requests

2 participants