0

I use the GWT ScriptInjector to inject an external JavaScript file like this:

ScriptInjector.fromUrl("http://example.com/foo.js").setCallback(
     new Callback() {
        public void onFailure(Exception reason) {
          Window.alert("Script load failed.");
        }
        public void onSuccess(Void result) {
          Window.alert("Script load success.");
        }
     }).inject();

This works fine but not expires header is set, i.e., the browser does not cache this script.

Is it possible to set a header for the ScriptInjector to cache the external js file?

1 Answer 1

1

You cannot set headers on a resource that you do not control. Most likely, the owner of this script already set headers to allow caching if this script does not change often.

If you do control this file, however (i.e. this script is on your server), you set the headers the same way that you do on any other static resource.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.