<commit_before>var md5 = require('md5');

module.exports = function (Vue) {

    Vue.http.interceptors.unshift(function () {

            var hit = true, key, lifetime;

            return {
                request: function (request) {

                    if (request.cache !== undefined && /^(GET|JSONP)$/i.test(request.method)) {

                        if (_.isObject(request.cache)) {
                            lifetime = request.cache.lifetime;
                            key = '_resource.' + request.cache.key;
                        } else {
                            lifetime = request.cache;
                            key = md5(JSON.stringify(request));
                        }

                        hit = Vue.cache.get(key);
                        if (hit) {
                            request.client = function () {
                                return hit;
                            };
                        }
                    }

                    return request;
                },

                response: function (response) {

                    if (!hit && response.ok) {
                        Vue.cache.set(key, response, lifetime);
                    }

                    return response;
                }
            };

        }
    );

};<commit_msg>update request cache<commit_after>var md5 = require('md5');

module.exports = function (Vue) {

    Vue.http.interceptors.unshift(function () {

            var hit = true, key, lifetime;

            return {
                request: function (request) {

                    if (request.cache !== undefined && /^(GET|JSONP)$/i.test(request.method)) {

                        if (_.isObject(request.cache)) {
                            lifetime = request.cache.lifetime;
                            key = '_resource.' + request.cache.key;
                        } else {
                            lifetime = request.cache;
                            key = '_resource.' + md5(JSON.stringify(request));
                        }

                        hit = Vue.cache.get(key);
                        if (hit) {
                            request.client = function () {
                                return hit;
                            };
                        }
                    }

                    return request;
                },

                response: function (response) {

                    if (!hit && response.ok) {
                        Vue.cache.set(key, response, lifetime);
                    }

                    return response;
                }
            };

        }
    );

};
{'fraction_non_alphanumeric': 0.10136157337367625, 'fraction_numerical': 0.0022692889561270802, 'mean_word_length': 0.8017711171662125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6941374', 'n_tokens_mistral': 627, 'n_tokens_neox': 568, 'n_words': 109}