diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index ffb09f22d6..b08191ebbb 100644
--- src/wp-includes/functions.php
+++ src/wp-includes/functions.php
@@ -3303,7 +3303,7 @@ function _config_wp_siteurl( $url = '' ) {
  * @access private
  */
 function _delete_option_fresh_site() {
-	update_option( 'fresh_site', 0 );
+	update_option( 'fresh_site', '0' );
 }
 
 /**
diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
index b38ddbd1f3..0954faa21d 100644
--- tests/phpunit/tests/customize/manager.php
+++ tests/phpunit/tests/customize/manager.php
@@ -170,18 +170,37 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
 		$this->assertInstanceOf( 'WPDieException', $exception );
 		$this->assertContains( 'Invalid changeset UUID', $exception->getMessage() );
 
-		update_option( 'fresh_site', 0 );
+		update_option( 'fresh_site', '0' );
 		$wp_customize = new WP_Customize_Manager();
 		$wp_customize->setup_theme();
 		$this->assertFalse( has_action( 'after_setup_theme', array( $wp_customize, 'import_theme_starter_content' ) ) );
 
 		// Make sure that starter content import gets queued on a fresh site.
-		update_option( 'fresh_site', 1 );
+		update_option( 'fresh_site', '1' );
 		$wp_customize->setup_theme();
 		$this->assertEquals( 100, has_action( 'after_setup_theme', array( $wp_customize, 'import_theme_starter_content' ) ) );
 	}
 
 	/**
+	 * Test that clearing a fresh site is a no-op if the site is already fresh.
+	 *
+	 * @ticket 38991
+	 */
+	function test_fresh_site_flag_clearing() {
+		global $wp_customize, $wpdb;
+
+		// Make sure fresh site flag is cleared when publishing a changeset.
+		update_option( 'fresh_site', '1' );
+		do_action( 'customize_save_after', $wp_customize );
+		$this->assertEquals( '0', get_option( 'fresh_site' ) );
+
+		// Make sure no DB write is done when publishing and a site is already non-fresh.
+		$query_count = $wpdb->num_queries;
+		do_action( 'customize_save_after', $wp_customize );
+		$this->assertEquals( $query_count, $wpdb->num_queries );
+	}
+
+	/**
 	 * Test WP_Customize_Manager::setup_theme() for frontend.
 	 *
 	 * @covers WP_Customize_Manager::setup_theme()
