Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
Offline
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
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
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
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
Offline
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
Offline
Re: etc_cache: cache trying hard to be smart
I was trying so many different things back and forth to get it working… I currently had the non-zipped version installed. Now I have version 0.5.3 and I see the advanced option. I put it to static files.
Everything is working better now but I still experiencing problems.
At least the “unpredictable” behaviour seems to be gone since using the correct version.
When editing now an article of the filtered section {“article_saved”:{“Section”:“jobs”}} it flushes the cache as expected. But when calling the url /jobs/ to regenerate the cache I get a blank page. Only reloading again shows the correct page and cache is created.
My goal would be anyway to overcome this step of the “manual” refreshment of the cache. For my purpose it would be best that the cache is generated somehow automatically in the moment the article is saved.
Offline
Re: etc_cache: cache trying hard to be smart
demoncleaner wrote #330463:
When editing now an article of the filtered section {“article_saved”:{“Section”:“jobs”}} it flushes the cache as expected. But when calling the url /jobs/ to regenerate the cache I get a blank page. Only reloading again shows the correct page and cache is created.
Interesting. Some web hosts or CSP rules block automated requests, requiring User-Agent or other headers. Have you anything like this in access logs?
Offline
Re: etc_cache: cache trying hard to be smart
I do not use any headers because it is just HTML-snippets that I wanted to create and integrate into my shop. But giving the database-cache-version of etc_cache a try made me realize that at the end it is more complicated using a caching-system to achieve what I want, when I can instead just look up the textpattern table directly and get the data from there. The approach is a bit different but it works pretty well. I just cannot use forms inside articles. But I can live with this.
Thank you anyway because you brought me on the right track.
Offline
Re: etc_cache: cache trying hard to be smart
Sure, there is no much point in storing data on disk rather than in db if you retrieve it via an application. The aim of static cache is to bypass any processing and serve static web pages directly to the client.
Anyway, that was an occasion to revisit etc_cache, so version 0.6 is out. It allows for setting cache update filters automatically on cache creation, without visiting the admin interface. If additionally you write a tiny admin-side plugin that pings the article’s URL on new article post, txp will become a (simple) static site generator, updating relevant pages when needed.
Offline
Re: etc_cache: cache trying hard to be smart
Hi, thank you for this awesome plugin 🙏
I’m trying to create a dynamic cache with a filter, but the filter attribute value does not show up in the plugin UI.
Here’s my code:
<txp:etc_cache id="schedule" reset="article_saved" filter='{"article_saved":{"Section":"schedule"}}'>my extremely heavy code</txp:etc_cache>
I want the cache to update only when there is any change to articles in my “schedule” section please.
If I set the filter manualy in the plugin UI, then when the cache gets updated, the filter value is once again gone.
I’m using the zipped version 0.6.
Another thing is that in the zipped version the “Cached at” column in the plugin UI doesn’t shows the time but only the date, in the TXT version (0.3) it does much better by showing the full date and time.
Edit: I’m using Textpattern version: 4.8.8
Last edited by THE BLUE DRAGON (2024-07-18 20:10:26)
Offline