Recently, I made a campus radio station with the project owner. after entering the station, the song will be automatically played, and the new JSON will be randomly obtained after each first release, and then the next one will be played.
The overall structure is like the command line style. At the end, input commands such as next and start to operate. The 5 + m/s campus network + w-level library is awesome.
I promoted it among my colleagues, but it was well received.
There are also many bugs and code bugs in the product design feedback. The most funny one is that in IE browser, each new song is
I thought it was a JS Code running in IE before debugging. Later I found that JS has no bugs.
After opening the debugging tool, the reason is clear: the Ajax returned result http304... each request is cached, and chrome and other browsers normally return 200.
Ajax cache = IE is omnipotent. Σ (° △° |) bytes )︴
! Ajax cache =! Second (second) Second
If the cause is found, the bug can be easily changed, so you don't want to cache or get the latest in real time.
[Solution]
Ajax requests under IE are cached Based on IP addresses and request routes, so the simplest method is as follows:
1. When a request is sent, a timestamp or random seed is automatically added at the end of the request link.
As above:/home/getmusic? Id = 1 + timestamp, which can be easily solved
2. Since it is cached, it will not be cached.
Front-end page disable cache: <meta HTTP-EQUIV = "Pragma" content = "no-Cache">
Front-end Ajax disabling Caching:
Cache parameters for Ajax requests: Required Boolean parameters. The default value is true (when datatype is script, the default value is false ). Setting false does not load request information from the browser cache.
Backend:
. Net: Response. cachecontrol = "no-Cache ";
PHP: Header ("cache-control: No-cache, must-revalidate ");
Header ("Pragma: No-Cache ");
In a word, save it for the first time.