• phlaix

    (@phlaix)


    Hi!

    My problem is or at least sounds simple. I wrote a tiny plugin with enables users to add a shortcode which displays a css-only image-slider. The images are generated from entries in a *.xml-file and are updated on calling a cron-job. The images are pulled from remote URLs and stored in the local plugin-folder.

    My problem is that when I call the cron-job it runs smoothly, files get updated (new banner at remote location is pulled, replacing the current one), but the front-end still shows the old one. I can only resolve it by adding a ?v=xxx at the end of the image URL which sucks.

    I do not use any caching plugins. It’s also not my browser cache, it’s the same behaviour on a fresh system which has never seen the website before.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Kyle Pott

    (@kylepott)

    Hey there!

    To sum up, you’ve got everything working, but your last call requires passing in an an argument to the front end which clutters the URL. I’m going to assume your front end is a PHP page, but correct me if I’ve got that wrong. Also I assume you’re talking about unix cron, but can you clarify if you mean WP Cron?

    Instead of calling the PHP function and passing the argument through the URL, have you tried adding one last line to your cron job that passes the argument in directly? This would be the same functionality, just moving your last call from the frontend into cron and then it would keep the URL looking clean.

    /usr/bin/php path/to/frontend/index.php v=xxx

    https://stackoverflow.com/questions/3872679/cron-jobs-calling-a-php-script-with-variables

    Kyle

    • This reply was modified 7 years ago by Kyle Pott.
    Thread Starter phlaix

    (@phlaix)

    Hi Kyle!

    My hope was to not need an argument at all. I only use the cron for being lazy. There is no real need, since updates happen like twice per year, so I can also call the updater manually. So I’ll attach a simple sketch of how the plugin is built. (Yes, ugly since I’m a newbie on this, backend for updating things etc might follow, but it works for now).

    So the plugin has two “main files”. One php-file (images.php) which gets called by using the shortcode in the frontend. And a second one which is only the updater (update.php). The updater uses cURL to grab the remote files defines in an XML and replaces the local ones. From my understanding after running the updater the frontend should just show the updated images. But it doesn’t. Why?

    https://drive.google.com/open?id=1oRgYrD9_doWPAeXfQdQiawRdd-utaXO6og (I hope it’s understandable)

    You can see the effect here:
    https://infurnity.com/wp-content/plugins/phx_banner_slider/assets/banner/nordic_fuzz_con.gif
    https://infurnity.com/wp-content/plugins/phx_banner_slider/assets/banner/nordic_fuzz_con.gif?v=2
    Those will give you different images, tho only one is on the server. Question is why? That’s obviously server-side caching of some sort. This also happens to me when using a fresh system/browser.

    Cheers~

    Kyle Pott

    (@kylepott)

    Good morning. The drawing definitely helps. Two things come to mind. One would be to run your whole install on a fresh host and server. This would just rule out any strange caching settings on your server set by your host.

    The second potential could be related to your shortcode logic. I’m hung up on the argument and thinking that may not be getting passed as you’d like.

    Without seeing your code it’s hard to know, but just guessing here, there is an argument you are passing that differentiates the images somehow, that argument could be passed from footer.php to images.php may not be operating the way you intend it.

    I know you don’t want to have an argument at all, but somehow that is making your code work as you intend – I’d spend some time tracing what’s happening when you send the argument and that may lead you in the right direction.

    Good luck!

    Kyle

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Image from plugin not updating’ is closed to new replies.