mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	Add Cache-Control and Pragma Header (#18406)
* Add Cache Control and Pragma to Asset Servlet * Add on null Or Empty
This commit is contained in:
		
							parent
							
								
									f45c5ddf5e
								
							
						
					
					
						commit
						35d1053dc0
					
				| @ -1,5 +1,7 @@ | |||||||
| package org.openmetadata.service.exception; | package org.openmetadata.service.exception; | ||||||
| 
 | 
 | ||||||
|  | import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty; | ||||||
|  | 
 | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import javax.servlet.ServletException; | import javax.servlet.ServletException; | ||||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||||
| @ -13,6 +15,8 @@ import org.openmetadata.service.config.OMWebConfiguration; | |||||||
| 
 | 
 | ||||||
| @Slf4j | @Slf4j | ||||||
| public class OMErrorPageHandler extends ErrorPageErrorHandler { | public class OMErrorPageHandler extends ErrorPageErrorHandler { | ||||||
|  |   private static final String CACHE_CONTROL_HEADER = "Cache-Control"; | ||||||
|  |   private static final String PRAGMA_HEADER = "Pragma"; | ||||||
|   private final OMWebConfiguration webConfiguration; |   private final OMWebConfiguration webConfiguration; | ||||||
| 
 | 
 | ||||||
|   public OMErrorPageHandler(OMWebConfiguration webConfiguration) { |   public OMErrorPageHandler(OMWebConfiguration webConfiguration) { | ||||||
| @ -88,6 +92,16 @@ public class OMErrorPageHandler extends ErrorPageErrorHandler { | |||||||
|     // Policy Permission |     // Policy Permission | ||||||
|     webConfiguration.getPermissionPolicyHeaderFactory().build().forEach(response::setHeader); |     webConfiguration.getPermissionPolicyHeaderFactory().build().forEach(response::setHeader); | ||||||
| 
 | 
 | ||||||
|  |     // Cache-Control | ||||||
|  |     if (!nullOrEmpty(webConfiguration.getCacheControl())) { | ||||||
|  |       response.setHeader(CACHE_CONTROL_HEADER, webConfiguration.getCacheControl()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Pragma | ||||||
|  |     if (!nullOrEmpty(webConfiguration.getPragma())) { | ||||||
|  |       response.setHeader(PRAGMA_HEADER, webConfiguration.getPragma()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     // Additional Headers |     // Additional Headers | ||||||
|     webConfiguration.getHeaders().forEach(response::setHeader); |     webConfiguration.getHeaders().forEach(response::setHeader); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Mohit Yadav
						Mohit Yadav