WordPress.com Security Rules Causing Issues with Adding Expires Headers for SEO
-
I am currently facing issues with adding Expires Headers to my website hosted on WordPress.com. I followed the recommended method of adding the headers to my .htaccess file, but it did not work. Upon further research, I learned that WordPress.com does not allow direct access to the .htaccess file.
I then tried to add the Expires Headers using a custom function in the functions.php file. However, upon saving the changes, I received an error message stating ‘Scrape key check failed. Please try again.’ I believe this error is caused by the security rules implemented by WordPress.com.
I understand that these security rules are in place for the safety and security of my website, but they are causing issues with implementing important SEO practices such as adding Expires Headers. Without these headers, my website’s load times may be slower, which can negatively impact my search engine rankings.
I have reached out to WordPress.com support livechat before for assistance, but they have not been able to provide a solution to the problem. I am looking for advice on how to add Expires Headers to my website while still adhering to WordPress.com’s security rules.
Has anyone else faced similar issues when trying to implement SEO best practices on their WordPress.com website? How did you resolve them? Any advice or guidance would be greatly appreciated.
Thank you.
WP.com: Yes
Jetpack: Yes
Correct account: YesThe blog I need help with is: (visible only to logged in users)
-

My site down with this error when i tried to add:
// Add HEADERS FOR LightSPeed Cache to files function add_browser_cache_headers() { header("ExpiresActive on"); header("ExpiresByType application/pdf A31557600"); header("ExpiresByType image/x-icon A31557600"); header("ExpiresByType image/vnd.microsoft.icon A31557600"); header("ExpiresByType image/svg+xml A31557600"); header("ExpiresByType image/jpg A31557600"); header("ExpiresByType image/jpeg A31557600"); header("ExpiresByType image/png A31557600"); header("ExpiresByType image/gif A31557600"); header("ExpiresByType image/webp A31557600"); header("ExpiresByType video/ogg A31557600"); header("ExpiresByType audio/ogg A31557600"); header("ExpiresByType video/mp4 A31557600"); header("ExpiresByType video/webm A31557600"); header("ExpiresByType text/css A31557600"); header("ExpiresByType text/javascript A31557600"); header("ExpiresByType application/javascript A31557600"); header("ExpiresByType application/x-javascript A31557600"); header("ExpiresByType application/x-font-ttf A31557600"); header("ExpiresByType application/x-font-woff A31557600"); header("ExpiresByType application/font-woff A31557600"); header("ExpiresByType application/font-woff2 A31557600"); header("ExpiresByType application/vnd.ms-fontobject A31557600"); header("ExpiresByType font/ttf A31557600"); header("ExpiresByType font/otf A31557600"); header("ExpiresByType font/woff A31557600"); header("ExpiresByType font/woff2 A31557600"); } add_action('send_headers', 'add_browser_cache_headers');And when tried to add them using the theme editor, i got an error: Scrape key check failed. Please try again.
The main code should be added to .htaccess ((which is not possible in wp.com since they’re not Apache)):
<IfModule mod_expires.c> ExpiresActive on ExpiresByType application/pdf A31557600 ExpiresByType image/x-icon A31557600 ExpiresByType image/vnd.microsoft.icon A31557600 ExpiresByType image/svg+xml A31557600 ExpiresByType image/jpg A31557600 ExpiresByType image/jpeg A31557600 ExpiresByType image/png A31557600 ExpiresByType image/gif A31557600 ExpiresByType image/webp A31557600 ExpiresByType video/ogg A31557600 ExpiresByType audio/ogg A31557600 ExpiresByType video/mp4 A31557600 ExpiresByType video/webm A31557600 ExpiresByType text/css A31557600 ExpiresByType text/javascript A31557600 ExpiresByType application/javascript A31557600 ExpiresByType application/x-javascript A31557600 ExpiresByType application/x-font-ttf A31557600 ExpiresByType application/x-font-woff A31557600 ExpiresByType application/font-woff A31557600 ExpiresByType application/font-woff2 A31557600 ExpiresByType application/vnd.ms-fontobject A31557600 ExpiresByType font/ttf A31557600 ExpiresByType font/otf A31557600 ExpiresByType font/woff A31557600 ExpiresByType font/woff2 A31557600 </IfModule> -
Hi there,
We are not able to help directly with code troubleshooting but it’s worth noting that our managed hosting platform is already fully optimized for the needs of WordPress: https://wordpress.com/support/site-speed/
If I can ask, what is prompting you to add that code? For me your site seems quite fast to load when I visit. You are facing a performance issue of some kind or checking your site using a scanner of some kind?
Upon further research, I learned that WordPress.com does not allow direct access to the .htaccess file.
It may help to clarify that .htaccess files are usually only found on hosting providers that use Apache web servers. We use a different system (NGINX) which offers better performance. For that reason, code intended for an .htaccess file would not work on our service since it’s fully managed and not user-accessible. More info here: https://wordpress.com/support/php-environment/
Hope that helps. Please let us know if you have any more questions.
- The topic ‘WordPress.com Security Rules Causing Issues with Adding Expires Headers for SEO’ is closed to new replies.