Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • k 256 posts 654 karma points
    Aug 16, 2018 @ 13:51
    k
    0

    Expiry date on external scripts

    Hello,

    Is it possible to add an expiry date to script file : Ex : http://www.xxx.js.

    Can we do it on IIS ?

    Thanks for helping.

    Regards,

    Kusum

  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Aug 16, 2018 @ 13:59
    Damiaan
    0

    If you want static content (files on disk) to be served with an expiry date, then you can add in your web.config a staticContent

    <staticContent>
        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="14.00:00:00" />
    </staticContent>
    

    Is that what you are looking for?

  • k 256 posts 654 karma points
    Aug 16, 2018 @ 14:13
    k
    0

    Hello Damiaan,

    Thank you for your reply.

    I have already done the above for the static scripts. I want to add expiry date for external scripts.

    can you please help ?

    Thanks,

    K

  • Greg Hluska 25 posts 133 karma points
    Aug 16, 2018 @ 14:31
    Greg Hluska
    100

    That's tough, Kusum...

    Those expiry headers are set as part of the http response, so the external server sets that. You could try sending that organization an email to see if they'd be willing to change their expiry header, but honestly, I wouldn't do that if someone asked, and I'm usually agreeable to just about anything.

    The expires header is a great way to reduce server load, so if an external server sets one that's near, chances are good that they plan to update the resource frequently. Or, some resources don't have expiry headers, and that's usually a good sign that you can't rely upon that external script.

    If you want to resort to an ugly hack, you could write a script to go out, fetch that external script and store it as a static script yourself. I absolutely don't recommend doing that because then you'll just add another package to manually manage.

    Alternately, if the external server does not set any expiry headers, you might want to look to other options. Good server admins will set that for everything people would download, just because they don't want to incur load having the same users download the same script $x times a week. Would the license permit you to save the script and host it yourself?

  • k 256 posts 654 karma points
    Aug 17, 2018 @ 06:25
    k
    0

    Thanks for the reply Greg. It was very clear.

  • Greg Hluska 25 posts 133 karma points
    Aug 17, 2018 @ 06:44
    Greg Hluska
    0

    Thanks Kusum, that's kind of you to say! Sorry that I didn't have the answer you wanted to hear. :)

Please Sign in or register to post replies

Write your reply to:

Draft