• Plans & Pricing
  • Log in
  • Get started
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress 
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Get started
  • Sign up
  • Log in
About
  • Plans & Pricing
Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress  
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Jetpack App
  • Learn more
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Search
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Forums / WordPress.com Security Rules Causing Issues with Adding Expires Headers for SEO

WordPress.com Security Rules Causing Issues with Adding Expires Headers for SEO

  • Unknown's avatar
    arabreseller · Member · Mar 1, 2023 at 8:10 am
    • Copy link Copy link
    • Add topic to favorites Add topic to favorites

    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: Yes

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar
    arabreseller · Member · Mar 1, 2023 at 8:14 am
    • Copy link Copy link

    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>
  • Unknown's avatar
    staff-totoro · Staff · Mar 3, 2023 at 2:29 am
    • Copy link Copy link

    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.

Tags

  • account
  • design
  • has-jetpack
  • import
  • Jetpack
  • wpcombusiness
  • wpcomhelp

About this topic

  • In: Support
  • 2 participants
  • 2 replies
  • Last activity 3 years
  • Latest reply from arabreseller

Couldn't find what you needed?

Contact us

Contact us

Get answers from our AI assistant, with access to 24/7 expert human support on paid plans.

Browse our guides

Browse our guides

Find step-by-step solutions to common questions in our comprehensive guides.

WordPress.com

Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Professional Email
  • Website Design Services
  • WordPress Studio
  • Enterprise WordPress
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • WordPress.com Blog
  • Business Name Generator
  • Logo Maker
  • WordPress.com Reader
  • Accessibility
  • Remove Subscriptions
Help
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
  • Developer Resources
Company
  • About
  • Press
  • Terms of Service
  • Privacy Policy
  • Do Not Sell or Share My Personal Information
  • Privacy Notice for California Users
DeutschEspañolFrançaisBahasa IndonesiaItalianoNederlandsPortuguês do BrasilSvenskaTürkçeРусскийالعربيةעִבְרִית日本語한국어简体中文繁體中文English

Mobile Apps

  • Download on the App Store
  • Get it on Google Play

Social Media

  • WordPress.com on Facebook
  • WordPress.com on X (Twitter)
  • WordPress.com on Instagram
  • WordPress.com on YouTube

Automattic

Automattic
Work With Us
    • WordPress.com Forums
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • Manage subscriptions