• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

HTML problem

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    HTML problem

    Hi folks. Quick HTML problem that I hope someone can answer.

    How can I stop images being cached in a browser?

    I'm running a property website that allows photographs to be uploaded by users. New photos can be uploaded to replace existing ones, but the new photos don't appear on the webpage unless the browser is 'refreshed'.

    Any ideas?

    #2
    well

    I know two methods off the top of my head but I dont support spammers.

    :-)

    btw I charge a £50 handling fee for each item of uce.

    Comment


      #3
      Invoice in the post...

      As far as I recall, you are using Asp pages, so add this to the top of each page (or slap it in an include file):

      Response.expires = 0
      Response.ExpiresAbsolute = Now()-2
      Response.AddHeader "pragma","no-cache"
      Response.AddHeader "cache-control","private"
      Response.CacheControl="no-cache"

      Comment


        #4
        Re: Invoice in the post...

        Actually Mark,

        My spam idea is working better than my door-to-door leafletting at the moment.

        I've been a bit naughty and have started nicking email addresses from other property websites

        Cheers EddieC for the advice. I had the response.expires, but not the other stuff. So many thanks for that!

        Comment


          #5
          > How can I stop images being cached in a browser?

          and why the hell would you want 90% of bytesize that is static not cached? Thats very mean thing to do both for users who will suffer and for yourself who will pay extra for bandwidth. I can understand if you want to do for special case of upload/preview image only, but not for the whole site. If you are so hell-bent on caching for new images, then just create new filename for newly uploaded images, which could be a hash function of original filename + timestamp.

          Comment


            #6
            The website is for selling property online.

            The problem I had was that people were changing their property photos but this was not being reflected in the 'property search' function.

            As the photos are thumbnails, I can't see visitors too my site taking too much of a preformance hit.

            Comment


              #7
              Illegal javascript event tags or url parameters detected.

              Comment


                #8
                Can you expand on this Mr Prawn? I'm a bit worried now

                Comment


                  #9
                  You can't control image caching via asp you need to setup the caching restrictions in IIS directly.

                  launch the Internet Services Manager, navigate to the images directory in question, then right-click the folder, and choose Properties.
                  In the Properties dialog box, select HTTPHeaders, and then click Add. Enter the following three headers:

                  cache-control:no-cache
                  pragma:no-cache
                  expires:0

                  Its a lot easier in .Net mind

                  Comment


                    #10
                    Problem is my webhost doesnt allow me to change IIS settings.

                    The first example by EddieC does seem to work though.

                    Thanks for everyones help on this one

                    Comment

                    Working...
                    X