We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36799
    • 40 Posts
    Have a page on a site http://www.anotherharddayattheoffice.co.uk/rainradar.html that pulls in an image via a chunk {{rainradar}} and the code for the chunk is <img src="/weather/images/rainradar.jpg" width="700" height="529">

    Is there a way to use a snippet etc to make sure the page calls in the latest image and not one stored in cache - I've tried creating a couple of basic snippets along the lines of
    <?php
    include("weather/images/rainradar.jpg");
    ?>


    But this did not work - at the moment users have to refresh the page to see the latest image

    Many thanks
      • 33968
      • 863 Posts
      How is the image updated / generated? Does the filename change at all or just the image itself?
        • 36799
        • 40 Posts
        It's a manual update every now and again - and the image file name stays the same rainradar.jpg as per the chunk so it's just the actual image "content" that changes

        Hope that makes sense
          • 36404
          • 307 Posts
          hi,

          well, as Lucas says, it depends on the way you change this image

          - if you change the image with the RTE (tinyMCE or else) in the page content management, MODx refreshes the cache when you save your changes

          - if not (using a module or ftp for example), you can either set the page not to be cached or refresh the website cache in the manager, this way, your users will only suffer from their own cache... something that can be a real hassle but you've no control on...

          have swing
            réfléchir avant d'agir
            • 33968
            • 863 Posts
            In this case I assume you're referring to browser caching rather than MODx caching.

            I use an aggressive caching strategy on some of my sites, specifying static files such as css and image to be cached for up to a year. This greatly speeds up subsequent visits but causes problems when I need to change one of those files, as visitors who have already been to my site will have the old files cached.

            The solution is to change the filename which forces the browser to download the new file. You can actually keep the same filename but append a unique string (today's date works well) as a parameter like this:
            weather/images/rainradar.jpg?v=09052011
            

            I guess if you wanted you could create a plugin to add that for you whenever you save the image TV, would make things simple for you smiley
              • 36799
              • 40 Posts
              I thought there might be some php code that would refresh the page on the users machine prior to loading the page - though I have done a fair amount of searching and not posting on here - not least because my old logon was not recognised smiley