什么是cache.js和编译映射文件 [英] What are those cache.js and compilation-mappings files

查看:160
本文介绍了什么是cache.js和编译映射文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我收到了一个包含网页的软件包。我看到里面(在普通的html和js文件旁边)有一些JS文件。它看起来像这样:

Recently I received a package with web page. I see inside (beside normal html and js files) there are some JS files. It looks like this:

4A3674A3247236B3C8294D2378462378.cache.js
FE728493278423748230C48234782347.cache.js
compilation-mappings.txt

在.js文件中我看到Javascript被混淆或缩小。内部 compilation-mappings.txt 引用了 cache.js 。这些文件是由某种WEB IDE生成的吗?不幸的是,我没有机会获得有关这个wep页面是如何开发的信息。

Inside .js files I see Javascript which is obfuscated or minified. Inside compilation-mappings.txt the cache.js are referenced. Are these files generated by some kind of WEB IDE? Unfortunately I have no chance to get information how this wep page was developed.

推荐答案

这是一个用Java编写并编译的Web项目使用 GWT项目工具访问JS。

That is a web project coded in Java and compiled to JS using the GWT project tools.

GWT在手工编写JS时,编译器会做很多手工操作,而在普通的JS项目中几乎不可能执行其他一些任务:混淆,压缩,死代码删除,每个浏览器的不同优化,重命名脚本,代码拆分等。

GWT compiler does a lot of the work you would have to do manually when coding JS by hand, and some other tasks which are almost impossible in a normal JS project: obfuscate, compress, death-code removal, different optimization per browser, renaming of the scripts, code splitting, etc.

您的应用程序中包含的内容是此编译的结果:

What you have in your app is the result of this compilation:


  1. 首先你应该拥有一个唯一的 index.html 文件,因为GWT用于生成RIA(富Internet应用程序),也称为SPI (单页界面)。

  1. First you should have a unique index.html file, because GWT is used to produce RIA (Rich Internet Applications) also known as SPI (Single Page Interface).

唯一的html文件应该引用一个名为 application_name.nocache.js的javascript文件。注意.nocache。部分,这意味着Web服务器应该设置适当的标头,因为它不是由代理或浏览器缓存的。这个文件非常小,因为它只是有代码来识别浏览器并要求下一个javascript文件。

The unique html file should have a reference to a javascript file named application_name.nocache.js. Note the .nocache. part, meaning that the web server should set the appropriate headers, so as it is not cached by proxies nor browsers. This file is very small becaust it just have the code to identify the browser and ask for the next javascript file.

这第一个脚本知道哪个 NNNN.cache.js 必须加载每个浏览器。 NNNN前缀是在编译应用程序时生成的唯一编号,并且每个浏览器都是不同的。 GWT支持6种不同的浏览器平台,所以通常你会有6个这样的文件。注意.cache。名称的一部分,意味着这些文件可以永久缓存。它们是大文件,因为它具有您应用程序的所有代码。

This first script knows which NNNN.cache.js have to load each browser. The NNNN prefix is a unique number which is generated when the app is compiled, and it is different for each browser. GWT supports 6 different browser platforms, so normally you would have 6 files like this. Note the .cache. part of the name, meaning that this files could be cached for ever. They are large files because have all the code of your application.

因此,您的应用程序的正常工作流程是浏览器询问可以缓存的 index.html 文件。此文件具有脚本标记,用于获取应始终向服务器请求的小启动脚本 applicaton.nocache.js 。它只有用于加载浏览器 NNNN.cache.js 的最新排列的代码,它将被永久地下载到您的浏览器中。

So the normal workflow of your app is that the browser ask for the index.html file which can be cached. This file has the script tag to get the small start script applicaton.nocache.js which should be always requested to the server. It has just the code for loading the most recent permutation for your browser NNNN.cache.js which will be downloaded cached in your browser for ever.

您有关于此内容的更多信息这里

You have more info about this stuff here

此命名约定的目标是下次用户访问应用程序时,它将位于缓存中 index.html NNNN.cache.js 文件,仅询问应用程序。 nocache.js 这真的很小。它保证用户始终加载最新版本的应用程序,浏览器只会在应用程序代码下载,代理或缓存设备在发布新版本时不会破坏您的应用程序等。

The goals of this naming convention is that the next time the user goes to the app, it will be in cache the index.html and NNNN.cache.js files, asking only for the application.nocache.js which is really small. It guarantees that the user loads always the most recent version of the app, that the browser will download just once the code of your app, that proxies or cache devices do not break your app when releasing a new version, etc.

说,由于大的混淆,几乎不可能弄清楚代码检查javascript的东西是什么。您需要原始的.java文件来理解代码或进行修改。

Said that, it is almost impossible to figure out what the code does inspecting the javascript stuff because of the big obfuscation. You need the original .java files to understand the code or make modifications.

这篇关于什么是cache.js和编译映射文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆