Support » Plugin: Image and video gallery from Google Drive » Permanent links and caching

  • Hello, thanks for your work on the plugin!

    I found that there are few thing that would be great to implement.

    Firstly ThumbnailLink is alive for short period (under 60 minutes, usually less). Every time page is refreshed new link is generated and downloaded.
    Secondly it would be great to cache response for set time of period. I have used https://wordpress.org/plugins/flickr-justified-gallery/ and it’s implemented there. It makes the response much faster by storing the markup and whole response.

    Have you tried webContentLink? It is permanent https://developers.google.com/drive/api/v3/manage-downloads
    I have tried this and it works, the only problem I think I can’t set parameter (alt->medium) because i get link with “&export=download” which is kind of working, but I don’t think is best. I don’t have experience with google drive api to be sure how to implement it the best way

    Would be great to improve it

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author genabitu

    (@genabitu)

    Hi,
    thanks for the (very technical) suggestions.

    Could you please explain what would be the benefit of having a more permanent content link – currently, the link to the image as it is opened in the lightbox is permanent – for example this link is permanently set to this particular image, across all refreshes and even plugin updates.

    If you want the actual image to be persistent, what is the reason for that? Currently, I would consider that a bug, because the image could then be viewed using this link even after a gallery has been removed from the webpage – I consider that to be a security issue.

    With that said, I try to be open to suggestions if there are good arguments supporting them, so please go ahead and try to convince me 🙂

    Thanks,
    Marek Dědič

    Thread Starter jurij_c

    (@jurij_c)

    Hi Marek!

    The reason for my suggestion is that you can’t cache this response with not permanent links, and page generation as I understood from what I saw is every time new. When it would be cached the response would be faster because you don’t have to process everything and then wait for api response, then download pictures. You can keep this response for hour or 2 or whatever is good for user and then refresh it and keep it again.

    When I refresh page, it downloads pictures again and again, every time you refresh.

    You don’t notice it when there are 3 pics, but when there are 1-2 albums on one page it’s noticeable delay up to 3-5 sec in page generation. And page generation, and as result server response is longer. It is important for google.

    Greetings

    Thread Starter jurij_c

    (@jurij_c)

    Hello Marek, again

    And Maybe the first step for it would be great to implement as an option caching of response api and all the markup for the minimal time links are alive for sure.

    Plugin Author genabitu

    (@genabitu)

    Uff, so you’re talking about caching by the browser or the server? If you’re talking about server caching, I would suggest you use WP Supercache, it works with this plugin.

    Thanks,
    Marek Dědič

    Thread Starter jurij_c

    (@jurij_c)

    I was generally talking about both. Server and browser as separate.
    Now we are talking about server.
    For example I use wp total cache on that project. I haven’t tested if it improves and caches, maybe those plugin concepts are different. I will check.

    what I’m talking about is to use caching for api and response + maybe the whole output. It would be universal and also if somehow api died for new request it would have cached response to use (and + if used permanent links worked as long as needed).

    1) I haven’t implemented it, as far as I know you can use for example wordpress https://codex.wordpress.org/Transients_API.
    There is example https://wordpress.stackexchange.com/questions/73654/cache-remote-http-request-with-transients-api

    2) In plugin I have told you before(flickr) it uses different concept – it stores cache on disc. I didn’t dig into the code to see how it’s done.

    3) There is also https://codex.wordpress.org/Class_Reference/WP_Object_Cache but it is only for time of one request and can be cached for longer with plugins like wp total cache.

    Greeting

    Plugin Author genabitu

    (@genabitu)

    Hi,
    just wanted to let you know this issue isn’t forgotten, it’s just that I haven’t had time for the plugin recently (and I don’t feel there is anything major requiring urgent action). I expect to have some time allotted for the plugin in ~ a month, so I’ll look into it then.

    Thread Starter jurij_c

    (@jurij_c)

    Hello, thanks for letting me know!
    I am using your plugin and altered some of the functionality to suit best my needs, specially to have as less impact on page load times. So I will share with you, maybe some ideas will be good for you

    1) I have minified all frontend scripts and enqueue only one file. The order of scripts in than file is important in that case very much. It’s possible to rely on minify plugins, but it’s much better solution to have already minified file. You can include option to use minified file.
    2) Additionally I load that script by jquery ajax call($.getScript()) when it’s needed and when page is initially loaded. To determine when it’s needed I have used https://www.npmjs.com/package/lozad (which I use already for lazy loading pictures onsite) and bind it to .sgdg-gallery-container (so every gallery on page is observed). Initially I had idea to lazy load images from gallery, but it looks better to just lazy load script which then starts loading images. It was very important because it loaded a lot of files even if user didn’t reach gallery. The only downside is when there 2 and more galleries (script can be downloaded twice – you have to use $.ajaxSetup({cache: true}); to load jquery ajax call only once))
    3) Because I have dequeued scripts I had to hard code sgdgShortcodeLocalize configuration before loading minified script.
    4) in shortcode.js added to configuration widowLayoutStyle: ‘center’ which has 3 options. It can be for example = justified. It would be better to justify last image, looks much more better ( it was implemented by justified flickr plugin I have told you before.) I have used just center, because didn’t finish with justifying last image.
    5) Also in shortcode.js I have added targetRowHeightTolerance:0.15 . It makes not every raw equal, and I like this look better, I recommend to try it.

    And about some bugs I have noticed:
    1) when there are two galleries of pictures on one page: autoloading only works for 1 of them, not always the same (bug in shortcode.js).
    2) sgdgShortcodeLocalize is added twice when there 2 galleries.
    2) on frontend some of admin scripts and maybe styles(I don’t remember) are loaded.
    3) I wanted to disable adding hash (unique picture address) to browser address, but it’s possible only by removing code in js, would be great when it was an option.

    About links for pictures as permanent links: I haven’t worked on that, as for now it’s like it was

    I have noticed that you used caching for storing as transient sgdg_hash which is used then to get the gallery. So as continuation of idea from previous posts, maybe it would be great to cache whole response for minimal time when the links for images as 100% still reachable.

    If you need some more details let me know, I will gladly help.

    Plugin Author genabitu

    (@genabitu)

    Wow, that’s an impressive amount of work over there…

    We develop the plugin at https://github.com/skaut/skaut-google-drive-gallery, if you’d like to join and share some of your improvements, you would be very much welcome.

    1) Minification unfortunatelly goes against the WP plugin guidelines.
    2) Sounds very interesting
    3) Could that be done in dome other way? This of course doesn’t work globally…
    4) + 5) Styling tweaks, sound worth checking out.

    As for the bugs:
    1) If you mean that it only autoloads the first one (until it’s fully loaded) then that’s true, but I don’t really see what other behaviour there should be – if you mean something else, it’s probably a bug…
    2) Yep.
    2b) Oops. Shouldn’t have happened…
    3) Hmm, why would you want to do that? I see no reason why somebody would want to turn this off…

    Plugin Author Marek Dědič

    (@marekdedic)

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Permanent links and caching’ is closed to new replies.