deanmoses / zenphoto-json-rest-api

Rest API for Zenphoto
GNU General Public License v2.0
9 stars 1 forks source link

Cache json results #9

Open acrylian opened 7 years ago

acrylian commented 7 years ago

Since we use the normal front end theme urls, possibly the static_html_cache plugin could take this over later on.

deanmoses commented 7 years ago

Excellent idea! I actually cache the JSON on my site, but it didn't occur to me to integrate it into the plugin.

acrylian commented 7 years ago

I'll take a look if that can be added to the existing cache plugin. Should be possible to store .json instead of .html files. No need to re-invent things we basically already have.

deanmoses commented 7 years ago

Each JSON album references its prev, next, and parent albums... just enough info to navigate to them. I assume that'll interfere with JSON caching because the existing cache plugin probably just invalidates the cache of the album being modified.

acrylian commented 7 years ago

Not sure what you mean. The existing cache plugin caches statically and is only cleared if requested manually or if the set timeframe to self clear is reached.

We might need to extend the class within this plugin to use it. I think there is a lot we can reuse and adapt. It probably just needs some flexibility added what suffix to append to the cached files. Those could then just be either in a new subfolder /cache_html/json/ or we introduce a new one /cache_json/ for this.

I will try to take a look at this.

deanmoses commented 7 years ago

Ah, okay -- I thought it was like the image cache that invalidated when the image changed.

FYI, I have a custom Javascript front end to Zenphoto that also does administration. When it changes an album it also invalidates its cached JSON file. I believe it's secure because requests are limited to same domain and there's no way for end users to insert HTML or Javascript into the app, but I haven't thought it through all that deeply.

On Fri, Apr 7, 2017 at 3:38 AM, Malte Müller notifications@github.com wrote:

Not sure what you mean. The existing cache plugin caches statically and is only cleared if requested manually or if the set timeframe to self clear is reached.

We might need to extend the class within this plugin to use it. I think there is a lot we can reuse and adapt. It probably just needs some flexibility added what suffix to append to the cached files. Those could then just be either in a new subfolder /cache_html/json/ or we introduce a new one /cache_json/ for this.

I will try to take a look at this.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/deanmoses/zenphoto-json-rest-api/issues/9#issuecomment-292464771, or mute the thread https://github.com/notifications/unsubscribe-auth/AAy0AdfbCbs8oa2q-4GJWwJcVdy31Ay3ks5rtef1gaJpZM4M1cPs .

acrylian commented 7 years ago

The image cache is not cleared automatically actually. If an image is deleted, all cached sizes are also deleted. But otherwise all sizes are generally kept if you change sizes via options or custom ones via theme/plugins directly.