Register
Submit a solution
The challenge is finished.

Challenge Overview

Problem

Caching is useful and suprisingly complex feature of web browsers. It makes loading page faster. To understand more, please check https://www.codebyamir.com/blog/a-web-developers-guide-to-browser-caching

But we met problems when using Topcoder Direct App recently.

For example, you used direct app in the past, and we made some changes to static files (js and css files) and make a deployment. when you visiting the new deployed direct app, you using see wired page style (css problem) or functionality broken (js problems). The main causes is the raw html page returned by struts (JSP and Servlet) is new, while the browser used the cached js and css files, which causes problem.

Requirements

For this challenge, we'd like to figure out a way to add versioning support for static files (css and js files), so when a new deployment occurs, the browser know it needs to reload the static files instead of using cache.

One possible solution is adding version tag or timestamp of build time, like 

<link rel="stylesheet" href="/css/direct/screen.css?v=210789" media="all" type="text/css"/>

so when the value for v parameter changed, the browser know it need to be requested instead of using cache.

Expectation

1. if you check the paths, like /css/direct/screen.css?v=21078, /scripts/jquery-1.4.1.min.js, the static files are separated deployed into static server, so we can not easily handle at servlet level.
2. Clear the static version tags in current source code, so it will sit like 

 <link rel="stylesheet" type="text/css" media="screen" href="/css/direct/customFont.css"/>
 <script type="text/javascript" src="/scripts/jquery-1.4.1.min.js"></script>

not 
<link rel="stylesheet" href="/css/direct/dashboard.css?v=215352" media="all" type="text/css" />

3. update the build scripts to dynamically add a ?v=<<timstamp>> tag to these places when generating the deployment ear file
4. the new generated version tag will never be put into source code.

Local Setup

See https://github.com/appirio-tech/tc-common-tutorials/tree/master/docker/direct-app for how to setup and run direct app locally using Docker and Docker Compose.

Final Submission Guidelines

- Code Changes
- Build and Verification Steps

ELIGIBLE EVENTS:

2018 Topcoder(R) Open

Review style

Final Review

Community Review Board

Approval

User Sign-Off

ID: 30065233