It turn out that my apache configuration causing all js file treated as 'text/html'.
In /etc/httpd/conf.d/php.conf there is this line
AddType application/x-httpd-php .html .php .xml .js
i changed it to
AddType application/x-httpd-php .html .php .xml
restarting httpd and the service worker registered successfully.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…