Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#73 2021-02-16 14:03:26

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: etc_cache: cache trying hard to be smart

Well, here it is. You MUST uninstall etc_static before. Then install and (re)activate etc_cache and visit Advanced prefs for basic configuration.

Even if you don’t need static cache and have etc_cache already installed, you might want to update it for improved admin tab markup.

Offline

#74 2021-02-17 16:12:35

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: etc_cache: cache trying hard to be smart

jakob wrote #320095:

I’m curious: I get why the txp:tag can’t be added to the filter field in the Extensions » etc_cache panel, but if it were possible to pass the filter as an attribute of the tag, like you can with reset, would the tag-in-tag variant work? My thinking was that the tag-as-attribute would be processed first and the results passed to etc_cache.

Finally, in today’s version one can set filter on the public side via id/form-less <txp:etc_cache /> blocks:

<txp:etc_cache reset="article_save">
"article_save":{"ID":<txp:article_id />}
</txp:etc_cache>

will make all subsequent cached blocks in the current article be updated only on this article’s update.

Offline

#75 2021-02-18 13:21:03

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: etc_cache: cache trying hard to be smart

After many trial and error .htaccess cycles, I have managed to make static cache work on my plugins site. The lines to add were in my case

    RewriteCond %{REQUEST_METHOD} =GET
    RewriteCond %{QUERY_STRING} ^$
    RewriteCond /path/to/site/cache/$1 -f [OR]
    RewriteCond /path/to/site/cache/$1index.html -f
    RewriteRule ^(.*) cache/$1 [PT,L]

    RewriteCond %{REQUEST_METHOD} =GET
    RewriteCond %{QUERY_STRING} ^$
    RewriteCond /path/to/site/cache/$1.html -f
    RewriteRule ^(.*) cache/$1.html [PT,L]

where /path/to/site is the value of $path_to_site variable from Diagnostics. Now I get ~ 180ms/80ms ratio between dynamic and static pages. Not as much as Varnish could give, but better than nothing.

Offline

#76 2021-02-18 17:15:00

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: etc_cache: cache trying hard to be smart

etc wrote #328953:

~ 180ms/80ms ratio

better than nothing.

The static pages are rather important for robustness of a website, its fault resistance, for accessibility of hypertext guides, references, books, usually published once.

Offline

#77 2021-02-18 18:08:47

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: etc_cache: cache trying hard to be smart

My debut in regex programming :)

Let’s replace the last line of URL Toolkit ID = Textpattern for Hiawatha webserver

Match [^?]*(\?.*)? Rewrite /index.php$1

to

Match [^?]*\/(|index\.php)\?([^?]+=[^?]+) Rewrite /index.php$2

and append it by this rule-set for static delivery:

RequestURI exists Return
Match ^/$ Rewrite /cache/index.html
Match ^/([^?]+)/$ Rewrite /cache/$1/index.html
Match ^/([^?]+[^/])$ Rewrite /cache/$1.html

Still tested on Regexpal.com only, not on a live website.

Offline

#78 2021-02-18 19:08:06

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: etc_cache: cache trying hard to be smart

Vienuolis wrote #328967:

RequestURI exists Return

If this is testing the right hand sides of each Match rule below, then Hiawatha is much easier to configure than Apache.

Offline

#79 2021-06-14 05:53:02

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: etc_cache: cache trying hard to be smart

I am trying hard to be smart – but just can´t get there.
(@etc wanted to write you back but end up beeing blocked as spam)

I first tried it with etc_static (because I need static files for what I try to achieve).
Then I was told etc_static ist obsolete and I should work with etc_cache instead.

Now I think there are multiple things going wrong. I am not sure if my whole setup (textpattern inside a shopping system in its own subdirectory) manipulates the cache folder in an unwanted way.

But let´s keep that aside for a moment to not complicate it.

First of all I am wondering how etc_cache is really a substitution for etc_static in my case. I cannot figure out how etc_cache is generating static files. All I can see is that it stores the cache in the database. That is my first issue I would like to solve. Is there a misunderstanding of some kind?

Offline

#80 2021-06-14 06:49:05

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: etc_cache: cache trying hard to be smart

To give it a try I changed my setup so that the cache can be served from the database.
That almost works but I am experiencing similar issues than before.

When I work with {“article_saved”:{“Section”:“my_section_name”}} sometimes the cache is flushed and sometimes it doesn´t. On my page I have a fixed article and some live articles. All of the same section. Changing the fixed article always seems to get the desired behaviour. Changing the live articles results in flushing the cache sometimes and sometimes not.

Sometimes etc_cache from out of nothing tells me “no cached items are recorded”.
When I click on “Update” on a line in the cache panel it resets the filter and reset entries. Is that the idea behind the button “update” ?
It is so weird. It would be great of someone could help finding out what is going on.

Last edited by demoncleaner (2021-06-14 06:54:16)

Offline

#81 2021-06-14 06:56:06

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: etc_cache: cache trying hard to be smart

demoncleaner wrote #330456:

(@etc wanted to write you back but end up beeing blocked as spam)

Hi Christian,

that’s weird, no spam report on my end.

First of all I am wondering how etc_cache is really a substitution for etc_static in my case. I cannot figure out how etc_cache is generating static files. All I can see is that it stores the cache in the database. That is my first issue I would like to solve. Is there a misunderstanding of some kind?

IIRC, if etc_static worked fine, then etc_cache should work too, but it has few prefs to set. Have you checked whether ‘Enable static cache’ advanced pref is active?

Offline

#82 2021-06-14 07:06:04

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: etc_cache: cache trying hard to be smart

Ok I think I am still missing things.

Have you checked whether ‘Enable static cache’ advanced pref is active?

Where would I find the advanced prefs?

Last edited by demoncleaner (2021-06-14 07:07:13)

Offline

#83 2021-06-14 07:08:19

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: etc_cache: cache trying hard to be smart

demoncleaner wrote #330459:

Where would I find the advanced prefs?

First enable Preferences/Admin/Advanced options, then go to Advanced options.

Offline

#84 2021-06-14 07:11:24

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: etc_cache: cache trying hard to be smart

This is where it starts. Maybe my installation is somehow f…. up.
When I go to Advanced options I do not see anything etc_cache related. Just
“php functions enabled…”, “Custom form template types” and “Number of extra perser sweeps”

This is why I was confused and were asking if there is maybe some Advanced options elsewhere that I am not aware about.

Last edited by demoncleaner (2021-06-14 07:12:39)

Offline

Board footer

Powered by FluxBB