简体   繁体   English

PHP-缓存JavaScript

[英]PHP - Caching JavaScript

I have a php file, content.php, which includes a another php file, viedo.php. 我有一个php文件content.php,其中包括另一个php文件viedo.php。 Inside video.php i use a script tag to do some javascript stuff for displaying a video. 在video.php内部,我使用脚本标签来执行一些JavaScript内容以显示视频。 I was wondering if i were to put the script into an external javascript file, would that file be cachable, and if so, is this bad/good practice? 我想知道是否要将该脚本放入一个外部javascript文件中,该文件是否可缓存,如果这样,这是不好的/好习惯吗? My thinking is, since php builds the page when you navigate to the url, im not sure if the browser will be able to tell if the javscipt file was cached. 我的想法是,由于php在您导航到url时会构建页面,因此我不确定浏览器是否能够判断javscipt文件是否已缓存。

content.php content.php

<?php
include 'nav.php';
 // ...
include 'video.php';
 // ...
php include 'footer.php';
?>

video.php video.php

<div>
<div id="myDiv">This text will be replaced with a player.</div>
<script>
jwplayer("myDiv").setup({
    "file": "http://example.com/myVideo.mp4",
    "image": "http://example.com/myImage.png",
    "height": 360,
    "width": 640
});
</script>
</div>

是的,它将被缓存,是的一个好习惯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM