@@ -1682,18 +1682,15 @@ TEST_F(InPlaceRewriteContextTest, OptimizeForBrowserNegative) {
1682
1682
}
1683
1683
1684
1684
TEST_F (InPlaceRewriteContextTest, LoadFromFile) {
1685
+ const int64 kIproFileTtlMs = 15000 ;
1685
1686
options ()->file_load_policy ()->Associate (" http://www.example.com" , " /test/" );
1687
+ options ()->set_load_from_file_cache_ttl_ms (kIproFileTtlMs );
1686
1688
WriteFile (" /test/cacheable.js" , cache_body_ /* " alert ( 'foo ') "*/ );
1687
1689
1688
1690
Init ();
1689
1691
1690
- // TODO(jmarantz): currently we will not have caching headers on
1691
- // file-input-resources so we default to the implicit cache TTL.
1692
- // We should probably have a new config options for file-input
1693
- // TTL for use with in-place.
1694
- const int64 kIproFileTtl = RewriteOptions::kDefaultImplicitCacheTtlMs ;
1695
1692
FetchAndCheckResponse (cache_js_url_, cache_body_, true ,
1696
- kIproFileTtl , NULL , start_time_ms ());
1693
+ kIproFileTtlMs , NULL , start_time_ms ());
1697
1694
1698
1695
// First fetch misses initial cache lookup, succeeds at fetch and inserts
1699
1696
// result into cache. Also, the resource gets rewritten and the rewritten
@@ -1715,7 +1712,7 @@ TEST_F(InPlaceRewriteContextTest, LoadFromFile) {
1715
1712
ResetHeadersAndStats ();
1716
1713
SetTimeMs (start_time_ms () + ttl_ms_/2 );
1717
1714
FetchAndCheckResponse (cache_js_url_, " good:jm" , true ,
1718
- kIproFileTtl , etag_,
1715
+ kIproFileTtlMs , etag_,
1719
1716
start_time_ms () + ttl_ms_/2 );
1720
1717
// Second fetch hits the metadata cache and the rewritten resource is served
1721
1718
// out.
@@ -1737,7 +1734,7 @@ TEST_F(InPlaceRewriteContextTest, LoadFromFile) {
1737
1734
AdvanceTimeMs (2 * ttl_ms_);
1738
1735
ResetHeadersAndStats ();
1739
1736
FetchAndCheckResponse (cache_js_url_, " good:jm" , true ,
1740
- kIproFileTtl , etag_, timer ()->NowMs ());
1737
+ kIproFileTtlMs , etag_, timer ()->NowMs ());
1741
1738
CheckWarmCache (" third_fetch" );
1742
1739
1743
1740
// OK let's now move time forward a little and touch the file
@@ -1749,7 +1746,7 @@ TEST_F(InPlaceRewriteContextTest, LoadFromFile) {
1749
1746
WriteFile (" /test/cacheable.js" , cache_body_ /* " alert ( 'foo ') "*/ );
1750
1747
ResetHeadersAndStats ();
1751
1748
FetchAndCheckResponse (cache_js_url_, cache_body_, true ,
1752
- kIproFileTtl , NULL , timer ()->NowMs ());
1749
+ kIproFileTtlMs , NULL , timer ()->NowMs ());
1753
1750
EXPECT_EQ (0 , counting_url_async_fetcher ()->fetch_count ());
1754
1751
EXPECT_EQ (0 , http_cache ()->cache_hits ()->Get ());
1755
1752
EXPECT_EQ (0 , http_cache ()->cache_misses ()->Get ());
@@ -1764,15 +1761,15 @@ TEST_F(InPlaceRewriteContextTest, LoadFromFile) {
1764
1761
AdvanceTimeMs (1 * Timer::kSecondMs );
1765
1762
ResetHeadersAndStats ();
1766
1763
FetchAndCheckResponse (cache_js_url_, " good:jm" , true ,
1767
- kIproFileTtl , etag_, timer ()->NowMs ());
1764
+ kIproFileTtlMs , etag_, timer ()->NowMs ());
1768
1765
CheckWarmCache (" second_fetch_after_touch" );
1769
1766
1770
1767
// Now change the content.
1771
1768
AdvanceTimeMs (1 * Timer::kSecondMs );
1772
1769
WriteFile (" /test/cacheable.js" , " new_content" );
1773
1770
ResetHeadersAndStats ();
1774
1771
FetchAndCheckResponse (cache_js_url_, " new_content" , true ,
1775
- kIproFileTtl , NULL , timer ()->NowMs ());
1772
+ kIproFileTtlMs , NULL , timer ()->NowMs ());
1776
1773
EXPECT_EQ (0 , counting_url_async_fetcher ()->fetch_count ());
1777
1774
EXPECT_EQ (0 , http_cache ()->cache_hits ()->Get ());
1778
1775
EXPECT_EQ (0 , http_cache ()->cache_misses ()->Get ());
@@ -1787,7 +1784,7 @@ TEST_F(InPlaceRewriteContextTest, LoadFromFile) {
1787
1784
AdvanceTimeMs (1 * Timer::kSecondMs );
1788
1785
ResetHeadersAndStats ();
1789
1786
FetchAndCheckResponse (cache_js_url_, " new_content:jm" , true ,
1790
- kIproFileTtl , etag_, timer ()->NowMs ());
1787
+ kIproFileTtlMs , etag_, timer ()->NowMs ());
1791
1788
CheckWarmCache (" second_fetch_after_mutation" );
1792
1789
}
1793
1790
0 commit comments