Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#85 2021-06-14 07:13:02

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

Re: etc_cache: cache trying hard to be smart

Ah. Have you downloaded the zipped etc_cache version?

Offline

#86 2021-06-14 07:42:25

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

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

#87 2021-06-14 07:54:30

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

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

#88 2021-06-14 11:42:22

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

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

#89 2021-06-14 15:43:09

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

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

#90 2024-07-18 20:07:49

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#91 2024-07-20 18:25:28

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

Re: etc_cache: cache trying hard to be smart

I’m trying to create a dynamic cache with a filter, but the filter attribute value does not show up in the plugin UI.

OK I found the issue, in the plugin code there is a need to add the filter to the extract part inside the etc_cache function, as so:

change this:

    extract(lAtts(array(
        'id'    => empty($atts['form']) ? null : $atts['form'],
        'url'   => false,
        'form'  => '',
        'reset' => $reset,
        'time'  => true
    ), $atts));

to this:

    extract(lAtts(array(
        'id'    => empty($atts['form']) ? null : $atts['form'],
        'url'   => false,
        'form'  => '',
        'reset' => $reset,
        'filter' => $filter,
        'time'  => true
    ), $atts));

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.

And about this issue, I found out it is because you simplified your code to just use the archive_dateformat from the txp preferences, so I went to my site preferences and added %S to the archive date format and now it does shows the seconds. (can use any strftime values I guess)

———————————————-

Now I’m facing an other issue, it is with the article_posted event not working but only the article_saved does, I’m also do not know how to properly chain the events in the reset and filter attributes.

This code works (with article_saved event):

<txp:etc_cache id="schedule" reset="article_saved" filter='"article_saved": {"Section": "schedule"}'>extremly heavy code goes here...</txp:etc_cache>

But these aren’t (with article_posted event):

<txp:etc_cache id="schedule" reset="article_posted" filter='"article_posted": {"Section": "schedule"}'>extremly heavy code goes here...</txp:etc_cache>
<txp:etc_cache id="schedule" reset="article_posted,article_saved" filter='"article_posted": {"Section": "schedule"},"article_saved": {"Section": "schedule"}'>extremly heavy code goes here...</txp:etc_cache>
<txp:etc_cache id="schedule" reset="article_posted,article_saved" filter='"{article_posted": {"Section": "schedule"},"article_saved": {"Section": "schedule"}}'>extremly heavy code goes here...</txp:etc_cache>@

If possible I would also like to know the full list of txp events that are available to use please.
Once again, I’m using the zipped 0.6 version on TXP 4.8.8.

Offline

#92 2024-07-22 09:20:18

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

Re: etc_cache: cache trying hard to be smart

Sorry for the delayed reply, and thank you for the hints. I will take a look at it when time allows.

Offline

Board footer

Powered by FluxBB